Skip to content

Analyzer crashes when using new Function type syntax in an optional argument #30228

@natebosch

Description

@natebosch

dartanalyzer --version: dartanalyzer version 1.25.0-dev.2.0

If the new function type syntax is used inside an optional argument then dartanalyzer will crash. To repro create a file with:

String doStuff([String Function() argument]) => argument();

Then run the dartanalyzer on this file - see a stack trace:

Unhandled exception:
NoSuchMethodError: The getter 'element' was called on null.
Receiver: null
Tried calling: element
#0      Object._noSuchMethod (dart:core-patch/object_patch.dart:43)
#1      Object.noSuchMethod (dart:core-patch/object_patch.dart:47)
#2      TypeResolverVisitor.visitGenericFunctionType (package:analyzer/src/generated/resolver.dart:9942)
...

However analyzing this file works:

String doStuff(String Function() argument) => argument();

Either optional positional or optional named arguments cause a crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions