Inconsistent behavior of field promotion in irrefutable patterns. #3418
Labels
bug
There is a mistake in the language specification or in an active document
field-promotion
Issues related to addressing the lack of field promotion
flow-analysis
Discussions about possible future improvements to flow analysis
patterns
Issues related to pattern matching.
During the development of the patterns feature, we decided that refutable pattern matches should trigger type promotion of the scrutinee, but irrefutable pattern matches shouldn't. For example, this is allowed:
But this is a compile-time error:
I just realized that when I implemented field promotion, I forgot to follow these rules. Currently, field promotion works both in refutable and irrefutable pattern matches. For example:
If I had discovered this problem earlier, I would have just fixed it without raising a fuss. But since we've passed the branch cut deadline for 3.2, I wanted to get the language team's opinion about what to do. Should I:
Personally I lean towards either 1 or 4, but I'm curious what others think.
CC @dart-lang/language-team
The text was updated successfully, but these errors were encountered: