-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
Desugar patterns #6099
Desugar patterns #6099
Conversation
05c07e3
to
5854420
Compare
crates/compiler/can/src/operator.rs
Outdated
// Find `OptionalField`s and desugar the default value exprs. Also discard `SpaceBefore` and | ||
// `SpaceAfter` nodes so that patterns can be destructured over multiple lines. |
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.
Slight preference for removing this comment. I think it's pretty clear what the function does from the body, and it's pretty likely it will grow out of date if the logic is ever updated.
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.
Makes sense, removed
@@ -1231,6 +1231,54 @@ mod test_can { | |||
assert_eq!(problems, Vec::new()); | |||
} | |||
|
|||
#[test] |
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.
You might consider asserting on the can AST (you could print it back using
//! Pretty-prints the canonical AST back to check our work - do things look reasonable? |
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 moved the tests to test_mono
because that seemed simpler.
Traverse pattern ASTs and desugar two cases - Desugar optional record field default value expr. This expr might contain nodes that need to be desugared, such as binary operations. Failing to desugar this expr can cause an internal panic later in canonicalization. - Discard SpaceBefore and SpaceAfter nodes so that patterns can be destructured over multiple lines. Keeping these nodes can cause an internal panic later in canonicalization. Fixes [1]. [1]: roc-lang#5653.
5854420
to
0ccc713
Compare
Traverse pattern ASTs and desugar two cases
Desugar optional record field default value expr. This expr might contain nodes that need to be desugared, such as binary operations. Failing to desugar this expr can cause an internal panic later in canonicalization.
Discard SpaceBefore and SpaceAfter nodes so that patterns can be destructured over multiple lines. Keeping these nodes can cause an internal panic later in canonicalization. Fixes Problem compiling Tutorial example: Optional Record Fields #5653.