Unhelpful Error when using Extensions in Switch Statements #58963
Labels
area-front-end
Use area-front-end for front end / CFE / kernel format related issues.
cfe-dysfunctionalities
Issues for the CFE not behaving as intended
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
Hello, I've run into an issue on MacOS using the command line. I recently made some changes to my code around the same time as I upgraded flutter, so I spent several hours trying to debug this issue as a flutter issue before realizing that my change was actually the culprit and that this issue has nothing to do with Flutter.
I've managed to trace my problem; I refactored a switch expression into a switch statement to streamline some logic. Unfortunately, one of the conditions wasn't constant, but neither I nor the compiler managed to catch this error. See code below.
I have an extension that provides a
>= operator
, which I was using in the switch expression. This was working before. However, if I try to use that same extension in the switch statement, neither the analyzer nor compiler issue a warning or error. Instead, when I try to run the test, I get a pretty big, unhelpful error.Instead, I would expect:
Test Code
Compile-time Error
Dart Info
(Sorry, built the project with Flutter)
The text was updated successfully, but these errors were encountered: