-
Notifications
You must be signed in to change notification settings - Fork 379
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
assertMacroExpansion
should emit an error if member macro is applied to declaration that can’t have members
#2206
Comments
@ahoppen If I remember correctly, I am digging down to learn more about it, let me know if there any specific |
@ahoppen > swift run --package-path CodeGeneration Error: Fetching https://github.com/apple/swift-argument-parser.git
Fetched https://github.com/apple/swift-argument-parser.git (2.24s)
Computing version for https://github.com/apple/swift-argument-parser.git
Computed https://github.com/apple/swift-argument-parser.git at 1.2.3 (0.61s)
Creating working copy for https://github.com/apple/swift-argument-parser.git
Working copy of https://github.com/apple/swift-argument-parser.git resolved at 1.2.3
Building for debugging...
[272/272] Linking generate-swift-syntax
Build complete! (17.20s)
dyld[21618]: Library not loaded: @rpath/libc++.1.dylib <----------
Referenced from: <F5104EA3-23D6-34EC-B647-516182F5AFE8> ../swift-project/swift-syntax/CodeGeneration/.build/arm64-apple-macosx/debug/generate-swift-syntax
Reason: tried: '/usr/lib/swift/libc++.1.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/libc++.1.dylib' (no such file), '/Users/rajveersingh/GitHub-OpenSource/swift-project/swift-syntax/CodeGeneration/.build/arm64-apple-macosx/debug/libc++.1.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/libc++.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/libc++.1.dylib' (no such file), '/usr/lib/swift/libc++.1.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/libc++.1.dylib' (no such file), '/Users/rajveersingh/GitHub-OpenSource/swift-project/swift-syntax/CodeGeneration/.build/arm64-apple-macosx/debug/libc++.1.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/libc++.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/libc++.1.dylib' (no such file)
zsh: abort swift run --package-path CodeGeneration This issue regarding [It's also occurring in I have also tried adding a global env to PS: I have added a Swift Forums post as well. |
Looks like you figured out the If you have any concrete questions regarding this issue, I’m happy to answer them, otherwise I think the issue description describes the issue fairly well. We have some general documentation of how swift-syntax works hosted on https://swiftpackageindex.com/apple/swift-syntax/main/documentation/swiftsyntax |
If I understand correctly, we need to add a check inside the As an example if I created my custom macro that's only constrained for If my above intuition is right, could you highlight the appropriate file directories we are targeting currently? Regarding tests I suppose they all go in |
The check should be in I would suggest that you add the above test case to your swift-syntax checkout. If you run it, it should fail. And then you can debug how to fix it. |
In So to check for declaration, do we guard Also, I have added the snippet |
Is the following snippet the right way to do the check, as at the moment many other tests also fail due to this addition: guard declGroup.syntaxNodeType == VariableDeclSyntax.self else {
throw MacroExpansionError.declarationNotIdentified
}
|
@ahoppen |
From your description, that seems like the right direction but it’s usually easier to tell if you open a PR and there’s code to look at. |
…macro to declaration that can’t have members Resolves Issue apple#2206
…macro to declaration that can’t have members Resolves Issue apple#2206
…r macro to declaration that can’t have members Resolves apple#2206
When applying an attached member macro to e.g. a variable,
assertMacroExpansion
will currently happily swallow the attribute. It should, however, emit an error that member macros can’t be applied to variables (specifically, if the declaration is not aDeclGroupSyntax
). Ie. the following test case should emit an error.rdar://115562663
The text was updated successfully, but these errors were encountered: