-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[Parse] Introduce /.../
regex literals
#42119
Conversation
Source compat was run with it enabled in #41767 |
class DiagnosticQueue final { | ||
/// The underlying diagnostic engine that the diagnostics will be emitted | ||
/// by. | ||
DiagnosticEngine &UnderlyingEngine; |
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.
Let me propose an alternate design for DiagnosticQueue
:
- There is no
UnderlyingEngine
member DiagnosticQueue::DiagnosticQueue()
just adds aForwardingDiagnosticConsumer
toQueueEngine
emit()
just closes theQueueEngine
's transaction, flushing the tentative diagnostics out to consumers
I think that would mean you wouldn't have to modify DiagnosticEngine
at all. Does your design have advantages over that one? (It might—I'd like to hear about them.)
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.
So I did play about with ForwardingDiagnosticConsumer
a bit, the main issue is that is forwards directly to the consumers and bypasses the target engine altogether, so doesn't update any state on the engine (including hadAnyError
!). Now, we should definitely fix that, although it's not clear to me whether all of its clients actually want the diagnostic to be fully re-evaluated by the target engine. There are a couple of other things:
- We'd need to turn a
DiagnosticInfo
back into aDiagnostic
to be re-evaluated by the target engine (as it may need to become a tentative diagnostic). We'd need special handling to make sure e.g warning-as-error is preserved if the original diagnostic engine had it set. - Because we'd be emitting the diagnostic in a dummy engine, we'd lose the caching for decl rendering (though we probably ought to cache that on the
ASTContext
or in the evaluator).
I don't think there's anything here that can't be solved, but it seemed less clean to me than creating a dummy diagnostic engine to effectively serve as a Diagnostic
builder, which can then be passed onto a target engine. If we want ForwardingDiagnosticConsumer
to properly support being able to forward-and-re-evaluate a diagnostic, then I agree we should change this to do that. But either way we'll need DiagnosticEngine
changes I believe.
f50b382
to
1acb2c3
Compare
583d71f
to
f7babed
Compare
11ad996
to
0d59e88
Compare
This allows us to hold tentative diagnostics independent of other diagnostic transactions.
Queue up diagnostics when lexing, waiting until `Lexer::lex` is called before emitting them. This allows us to re-lex without having to deal with previously invalid tokens.
Change the flag to imply '-enable-experimental-string-processing', and and update some tests to start using it.
When forward slash regex is enabled, start emitting an error on prefix operators containing the `/` character.
This spelling is no longer used.
Start parsing regex literals with `/.../` delimiters. rdar://83253726
0d59e88
to
11ad996
Compare
I tried to be clever with the force pushing, but GitHub screwed up the timestamps so the above "force pushed" link is wrong. Correct diff is https://github.com/apple/swift/compare/11ad996fe954ee73c4e63b90cfaec1efed2ae23b..f1a799037e3d00ea530480a1d67c281524a29a42. |
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.
Looks good. Thank you!
@swift-ci please smoke test Linux |
Start parsing regex literals with
/.../
delimiters when-enable-bare-slash-regex
is passed.rdar://83253726