-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Disallow multi-line filenames and non-decimal line numbers in #sourceLocation
directive in Swift 6 mode
#71238
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
Disallow multi-line filenames and non-decimal line numbers in #sourceLocation
directive in Swift 6 mode
#71238
Conversation
Non-decimal line numbers in a `#sourceLocation` directive are simply confusing in my opinion and should be banned.
test/Parse/line-directive.swift
Outdated
// expected-warning@+1 {{expected starting line number for #sourceLocation directive; this is an error in Swift 6}} | ||
#sourceLocation(file: "x.swift", line: 0xff) | ||
|
||
#sourceLocation() | ||
|
||
// expected-warning@+1 {{'#sourceLocation' cannot be a multiline string literal; this is an error in Swift 6}} | ||
#sourceLocation(file: """ | ||
x.swift | ||
y.swift | ||
""", line: 42) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be worth adding tests for the error variants of these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think that’s necessary. The this is an error in Swift 6
is generated automatically by the warnUntilSwiftVersion(6)
and should just work.
test/Parse/line-directive.swift
Outdated
// expected-warning@+1 {{'#sourceLocation' cannot be a multiline string literal; this is an error in Swift 6}} | ||
#sourceLocation(file: """ | ||
x.swift | ||
y.swift | ||
""", line: 42) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For e.g #sourceLocation(file: "a\nb", line: 42)
, seems we just take the characters literally, not sure if we ought to ban escape sequences too to avoid confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, interesting. Let’s consider that a separate issue though. It’s probably not worth fixing it in the old parser anyway.
b133f5f
to
e6b41b7
Compare
@swift-ci Please smoke test |
…ation and similar locations This should allow us to eventually simplify parsing of simple string literals in the new parse by not having to handle indentation of multiline string literals.
e6b41b7
to
4a386d4
Compare
@swift-ci Please smoke test |
#sourceLocation
directive#sourceLocation
directive are simply confusing in my opinion and should be banned.