-
Notifications
You must be signed in to change notification settings - Fork 89
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
Let rec patterns #2031
Let rec patterns #2031
Conversation
Bencher
Click to view all benchmark results
Bencher - Continuous Benchmarking View Public Perf Page Docs | Repo | Chat | Help |
🎉 All dependencies have been resolved ! |
@jneem once it's rebased could please tag me, and I'll take a look! |
a6ceb15
to
b1611a1
Compare
b1611a1
to
73e7770
Compare
@yannham it's ready for a look |
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 like where this goes - although it's slightly harder to express than using a simple surface language desugaring, it's still very close (and a reasonable transformation, and a similar semantics). Plus the fact that the errors are now nicer.
cli/tests/snapshot/snapshots/snapshot__eval_stderr_destructuring_closed_fail.ncl.snap
Outdated
Show resolved
Hide resolved
cli/tests/snapshot/snapshots/snapshot__eval_stderr_destructuring_closed_fail.ncl.snap
Show resolved
Hide resolved
core/src/term/mod.rs
Outdated
let attrs = LetAttrs { | ||
binding_type: BindingType::Normal, | ||
rec: false, | ||
}; |
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.
Nitpick: I think this is the Default
implementation of LetAttrs
. But if you spell the values out on purpose to be more explicit that's fair too.
let attrs = LetAttrs { | ||
binding_type: BindingType::Normal, | ||
rec, | ||
}; |
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.
(another Default
instance)
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.
This one has a rec
...
core/src/typecheck/pattern.rs
Outdated
/// The type of each "leaf" identifier will be assigned based on the `mode` | ||
/// argument. The current possibilities are for each leaf to have type | ||
/// `Dyn`, or to be assigned a fresh unification variable. |
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.
Why did this comment change? Have we changed anything about type annotations in record patterns?
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.
Maybe I misunderstood, but it seemed to me that the code has only two cases (Dyn
for TypecheckMode::Walk
, and a unification variable for TypecheckMode::Enforce
). The previous comment made it sound like there were three cases.
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 think the third case is something like match x { {foo : Number, bar: String} => ...}
, where we take the type from the annotation instead. Or at least so I recall.
Depends on #2010
Allows
let rec
bindings to contain patterns. Also fixes a bug in lsp completions, where pattern bindings were accidentally already treated as recursive.The destructuring is no longer desugared to a match block (which allows for slightly better diagnostics), but it is still as eager as a match block destructuring and it still uses the same pattern compilation under the hood. The motivations for destructuring eagerly,
let 'Foo = 'Bar in true
won't error)