Skip to content

analyzer fuzz crash: old style function typed formal parameter with type args #38057

@MichaelRFairhurst

Description

@MichaelRFairhurst

This one is interesting because it is technically valid dart code!

class C {
  Function() f;
  C(this.f<T>());
}

This is technically a valid field initializer for f that constrains the type from Function() to Function<T>(). @leafpetersen if he cares to confirm/comment.

However this is the old way, and the new way works (class C { Function() f; C(Function<T> this.f); }). So this is an extremely edge case language feature.

_ElementMismatchException: Element mismatch in /test/lib/test.dart at dynamic Function(dynamic) fi
Caused by RangeError (index): Invalid value: Valid value range is empty: 0       
#0      List.[] (dart:core-patch/array.dart:166:52)                              
#1      ElementWalker.getTypeParameter (package:analyzer/src/generated/declaration_resolver.dart:951:22)
#2      DeclarationResolver.visitTypeParameter (package:analyzer/src/generated/declaration_resolver.dart:462:37)
#3      TypeParameterImpl.accept (package:analyzer/src/dart/ast/ast.dart:10253:49)
#4      NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7670:20)     
#5      TypeParameterListImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:10303:21)
#6      RecursiveAstVisitor.visitTypeParameterList (package:analyzer/dart/ast/visitor.dart:1296:10)
#7      TypeParameterListImpl.accept (package:analyzer/src/dart/ast/ast.dart:10299:49)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.crashProcess exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash.fuzz-dustfound with dust fuzz testingtype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions