Skip to content

Data race runtime warnings, when LanguageLayer is adding a new sub-layer #47

@dvclmn

Description

@dvclmn

Error message:

warning: data race detected: @MainActor function at
{PackageName}/{FileName}:{LineNumber} was not
called on the main thread

Here is the line highlighted by the purple runtime warning, from LanguageLayer.swift.

Here was the code used to initialise a TextViewHighlighter, that brought about the warnings.

It's just now occurred to me that the actual error is happening on code from SwiftTreeSitter, not Neon itself. Would you prefer me to post over there?

Neon is being used in my case from within a Swift Package, and the below snippet from my Package.swift was being used to enable strict concurrency checking:

for target in package.targets {
  target.swiftSettings = target.swiftSettings ?? []
  target.swiftSettings?.append(
    .unsafeFlags([
      "-Xfrontend", "-warn-concurrency",
      "-Xfrontend", "-enable-actor-data-race-checks"
    ])
  )
}

Removing this, and replacing it with the below, does make the warnings go away.

swiftSettings: [
    .enableExperimentalFeature("StrictConcurrency")
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions