You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, this issue is exactly the intent behind #2563.
I agree, it's very annoying. An earlier version of the proposal supported exactly this behavior but at the expense of not actually support real record patterns. The record pattern syntax was always just "destructure the thing, whatever it is", which worked well for objects but meant there was no actual pattern syntax for "test if the thing actually is a record and then destructure it".
When I fixed the proposal to make record patterns actually match records (and only records) it broke that affordance.
I believe we can get it back by saying that if the matched value type is not a record type of a supertype of Record then treat a record pattern as an object pattern with an inferred type. Unfortunately, we didn't have time to get that into 3.0, but maybe in a follow-on release.
If we have code like
Because we see that only
foo
andbar
properties are used, we decide to declare them by destructuring.Oh no! The expression
e
has a very long type name, which we have to repeat in the object pattern.This kills the whole idea of destructuring.
It would be nice if we did not have to repeat type names, just as we don't write them in
var foo = o.foo
.Maybe
var _(: foo, : bar) = e;
.The text was updated successfully, but these errors were encountered: