[cfe] Unhandled 'ReachabilityError' with record getter coercion #51404
Labels
area-front-end
Use area-front-end for front end / CFE / kernel format related issues.
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
Consider the following program:
This program is accepted by the analyzer (as expected). It is also accepted by the CFE, but both
dart
anddart compile js
give rise to executions where an unhandledReachabilityError
occurs when the second pattern declaration is reached.I'd expect these pattern declarations to be accepted at compile time, and also to be compiled to code where a coercion takes place during initialization of the variable
d
respectivelys3
: The matched value is obtained fromrecord
by invoking the getter$2
, and the return type of that getter isdynamic
, and hence there should be a dynamic type check when the initialization of each of those variables is just about to occur. So we'd expect the program to run the first pattern declaration successfully and then throw aTypeError
when it reaches the dynamic type check fors3
.However, it looks like the generated code is faulty, and some inconsistency is detected at the point where that dynamic type check could have taken place. In any case, it is certainly not obvious why we would encounter a
ReachabilityError
rather than aTypeError
.With the CFE from commit bedcd57, we get the following response from an execution of
dart
respectively the JS code generated bydart compile js
:The text was updated successfully, but these errors were encountered: