Pattern Matching on Sealed Classes with Default Generic Type Crashes Analyzer in Nested Functions #60264
Labels
area-devexp
Developer experience items (DevTools, IDEs, analysis server, completions, refactorings, ...).
P2
A bug or feature request we're likely to work on
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
I've discovered that using pattern matching with sealed classes works perfectly in global functions and class methods, but attempting the exact same code in a nested function crashes the Dart analyzer completely with error code -32013.
Steps to Reproduce
A simple implementation of Option type.
For the None type we use
Never
to avoid setting it.So for reproduce the error is important to set a default type for the parent class.
I use
Never
butT
can be any type.If we use a implementation like this, it will work.
Code Example
Expected Behavior
Should work consistently regardless of where the function is defined.
Dart analyzer logs
When uncommenting the nested function, the analyzer immediately crashes. The log shows that uncommenting the function (by removing comment markers) causes the analyzer to fail:
The analyzer repeatedly fails with the same error for all subsequent operations:
{"code":-32013,"data":"...","message":"Analysis failed for file"}
{"code":-32013,"data":"...","message":"Analysis failed for file"}
{"code":-32013,"data":"...","message":"Analysis failed for file"}
{"code":-32013,"data":"...","message":"Analysis failed for file"}
The editor becomes unusable until the nested function is removed or commented out again.
Environment
The text was updated successfully, but these errors were encountered: