Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-vfsoverlay breaks -strict-concurrency checking #73088

Open
jszumski opened this issue Apr 17, 2024 · 1 comment
Open

-vfsoverlay breaks -strict-concurrency checking #73088

jszumski opened this issue Apr 17, 2024 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@jszumski
Copy link

jszumski commented Apr 17, 2024

Description

Using a VFS overlay prevents strict concurrency checking from diagnosing valid violations in Swift 5.10.

Reproduction

# prepare the dependency
swiftc \
    -c ModuleMinimal/ExampleMinimal.swift \
    -strict-concurrency=minimal \
    -emit-module \
    -emit-module-path build/ModuleMinimal.swiftmodule \
    -module-name ModuleMinimal \
    -whole-module-optimization \
    -parse-as-library \
    -o build/ModuleMinimal.o

# use the dependency without VFS
#
# correctly outputs:
#   warning: static property 'one' is not concurrency-safe because it is not either conforming to 'Sendable'
#   or isolated to a global actor; this is an error in Swift 6
swiftc \
    -c ModuleComplete/ExampleComplete.swift \
    -strict-concurrency=complete \
    -emit-module \
    -emit-module-path build/ModuleComplete.swiftmodule \
    -module-name ModuleComplete \
    -whole-module-optimization \
    -parse-as-library \
    -I build \
    -o build/ModuleComplete.o \

# use the dependency with VFS
#
# incorrectly shows no output
swiftc \
    -c ModuleComplete/ExampleComplete.swift \
    -strict-concurrency=complete \
    -emit-module \
    -emit-module-path build/ModuleComplete.swiftmodule \
    -module-name ModuleComplete \
    -whole-module-optimization \
    -parse-as-library \
    -Xfrontend -vfsoverlay \
    -Xfrontend vfs-overlay.yaml \
    -I/vfs_swiftmodules \
    -o build/ModuleComplete.o
# ExampleMinimal.swift

import Foundation

public struct ExampleMinimal {
    public let number: Int

    public static let one = ExampleMinimal(number: 1) // a declaration that does not pass `strict-concurrency=complete`
}
# ExampleComplete.swift

import Foundation
import ModuleMinimal

public struct ExampleComplete {
    public let number: Int

    public init() {
        number = ExampleMinimal.one.number // expected to raise an issue here
    }
}
# vfs-overlay.yml

case-sensitive: true
overlay-relative: false
roots:
  - contents:
      - external-contents: build/ModuleMinimal.swiftmodule
        name: ModuleMinimal.swiftmodule
        type: file
    name: /vfs_swiftmodules
    type: directory
use-external-names: false
version: 0

Expected behavior

Compliations with and without VFS should show warning: static property 'one' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor; this is an error in Swift 6.

Environment

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)

Additional information

No response

@jszumski jszumski added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Apr 17, 2024
@jszumski
Copy link
Author

Repro: concurrency-vfs.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant