Skip to content

[patterns] Function pattern inconsistency between implementation and spec. #54246

Open
@modulovalue

Description

@modulovalue

Hello, again 😃

Consider:

void main() {
  if (() {} case Function()) {
    print("foo");
  }
}

On DartPad, it prints foo and terminates successfully. However, it looks like the spec does not intend for that to be possible. Function is not a typeIdentifier so objectPatterns do not describe Function() and there's no other pattern that explicitly introduces Function patterns.

 === Analyzer ===
Scan errors: 0
Parse errors: 0
...
        ┃  ┣━ <CaseClauseImpl> [26-41]
        ┃  ┃  ┣━ 'case' [26-30]
        ┃  ┃  ┗━ <GuardedPatternImpl> [31-41]
        ┃  ┃    ┗━ <ObjectPatternImpl> [31-41]
        ┃  ┃      ┣━ <NamedTypeImpl> [31-39]
        ┃  ┃      ┃  ┗━ 'Function' [31-39]
        ┃  ┃      ┣━ '(' [39-40]
        ┃  ┃      ┗━ ')' [40-41]
...
--------------------------------------------------------------------------------
 === ANTLR ===
line 2:17 missing ')' at 'Function'
Errors of type 1: [[@15,41:41=')',<7>,2:27], [@15,41:41=')',<7>,2:27], [@15,41:41=')',<7>,2:27], [@15,41:41=')',<7>,2:27]]
Errors of type 2: [<missing ')'>, Function, (, ), )]
line 2:17 missing ')' at 'Function'
<startSymbol>
┗━ <libraryDefinition>
  ┣━ <metadata>
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.model-patternsImplementation of patterns in analyzer/cfestatus-pending

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions