-
Notifications
You must be signed in to change notification settings - Fork 5
Closed
Labels
Description
Currently I can't do this:
test(x: [A(val: U32), B(val: Str)])
match x:
~A(val): printStr(val.toStr())
~B(val): printStr(val)
Because the fields are named, I have to do ~A(val = val) if I want to use the same name as the field, or ~A(val = anotherName) if I want to rename.
Instead we should probably allow the code above.
One potential issue is that, when looking at the pattern, it will be impossible to tell whether the pattern is matching A(val: ...) or A(...) (i.e. whether the variable is matching a named field without giving it a new name, or a positional field).
I doubt it's going to be a problem in practice though.
Reactions are currently unavailable