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

sourceLocation error in Swift 6 (but not Swift 5 or with slight modification) #74561

Closed
leptos-null opened this issue Jun 19, 2024 · 1 comment · Fixed by #75421
Closed

sourceLocation error in Swift 6 (but not Swift 5 or with slight modification) #74561

leptos-null opened this issue Jun 19, 2024 · 1 comment · Fixed by #75421
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. parser Area → compiler: The legacy C++ parser

Comments

@leptos-null
Copy link

Description

The Swift 6 toolchain reports parameterless closing #sourceLocation() directive without prior opening #sourceLocation(file:,line:) directive unexpectedly.

Reproduction

enum SomeType {
}

#sourceLocation(file: "Orig", line: 3)
func process(_ param: SomeType) {
#sourceLocation()
}

Compile with swiftc -c -emit-module-path bug_report -swift-version 5 -parse-as-library file.swift

Expected behavior

The sample code produces a module without errors.

Note that

// swiftc -c -emit-module-path bug_report -swift-version 5 -parse-as-library file.swift

enum SomeType {
}

#sourceLocation(file: "Orig", line: 3)
func process() {
#sourceLocation()
}

completes without errors.

Environment

Tested with

Reports error:

Apple Swift version 6.0-dev (LLVM de395d39a90ed7a, Swift 490cf64aee23f13)
Target: arm64-apple-macosx14.0

Reports error:

swift-driver version: 1.109.2 Apple Swift version 6.0 (swiftlang-6.0.0.3.300 clang-1600.0.20.10)
Target: arm64-apple-macosx14.0

No error:

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0

Additional information

No response

@leptos-null leptos-null added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Jun 19, 2024
@hborla hborla added parser Area → compiler: The legacy C++ parser and removed triage needed This issue needs more specific labels labels Jul 14, 2024
@leptos-null
Copy link
Author

Additional:

I'm not seeing an error reported in (Xcode 16.0 beta 3)

swift-driver version: 1.111.2 Apple Swift version 6.0 (swiftlang-6.0.0.5.15 clang-1600.0.22.6)
Target: arm64-apple-macosx14.0

But I do see the same error reported in the latest snapshot

Apple Swift version 6.0-dev (LLVM 0ad8ad0245d47b4, Swift 01bd2b4f8c84d45)
Target: arm64-apple-macosx14.0

Thanks to @FieryFlames for bringing the original issue to our attention and also the update that this appears to be working in Xcode 16.0 beta 3.

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. parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants