-
Notifications
You must be signed in to change notification settings - Fork 442
Remove CanImportExprSyntax
and provide API to interpret an ExprSyntax
as a VersionTupleSyntax
#1972
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
Comments
CanImportExprSyntax
and provide API to interpret an ExprSyntax
as a VersionTupleSyntax
CanImportExprSyntax
and provide API to interpret an ExprSyntax
as a VersionTupleSyntax
Tracked in Apple’s issue tracker as rdar://113236781 |
ahoppen
added a commit
to StevenWong12/swift-syntax
that referenced
this issue
Mar 15, 2024
…ression node To make it easier to interpret the version passed to `canImport(MyModule, _version: <#version#>)`, add `ExprSyntax.interpretedAsVersionTuple` that takes eg. `1.2.3`, which got parsed as a member access `3` to the `1.2` float literal and re-parses it as a `VersionTupleSyntax`. This relaxation also allows string literals as version parameters to `#if canImport`. Fixes swiftlang#1972 rdar://121070235 Co-Authored-By: Ziyang Huang <[email protected]>
ahoppen
added a commit
to ahoppen/swift-syntax
that referenced
this issue
Mar 19, 2024
…ression node To make it easier to interpret the version passed to `canImport(MyModule, _version: <#version#>)`, add `ExprSyntax.interpretedAsVersionTuple` that takes eg. `1.2.3`, which got parsed as a member access `3` to the `1.2` float literal and re-parses it as a `VersionTupleSyntax`. This relaxation also allows string literals as version parameters to `#if canImport`. Fixes swiftlang#1972 rdar://121070235 Co-Authored-By: Ziyang Huang <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
canImport
inside of#if
should get parsed the same as in a normal expression position, eliminating the need forCanImportExprSyntax
(sparked by link). This means that the parser won’t be able to generate diagnostics for invalid version numbers insidecanImport
anymore.Instead, we should have a function on
ExprSyntax
that interprets the expression (which would be aFloatingLiteralExprSyntax
for eg.1.2
) as aVersionTupleSyntax
. If theExprSyntax
doesn’t represent a version, that function should return a list of diagnostics.SwiftIfConfig
would then call that getter and would be responsible for reporting any errors that occur from interpreting theExprSyntax
of the_version
argument asVersionTupleSyntax
.The text was updated successfully, but these errors were encountered: