Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[parser/spec] initializerExpression inconsistency between the spec and implementation: the spec does not support some constructs supported by the implementation. #54271

Open
modulovalue opened this issue Dec 7, 2023 · 6 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language).

Comments

@modulovalue
Copy link
Contributor

@eernst wrote in #51482 (comment)

(Actually, looking at this, I believe initializerExpression should include throw and assignment expressions; but I've never seen any failures because they aren't currently included).

Here's one failure:

class AssertAlwaysThrows_Constructor {
Object a;
Object b;
AssertAlwaysThrows_Constructor(
Object o, Object p, bool Function(Object, Object) f)
: a = o is int ? true : throw 'x',
b = throw 'x',
assert(f(o = p, throw 'x')) {
/*int*/ o;
}
}

The spec does not appear to support throw expressions in constructor initializer expressions.

Throw expressions are supported by the implementation (actually, throwExpressionWithoutCascade), but not by the spec:

class Foo {
  int i = 0;
  Foo(int j) : i = throw 0;
}
 === Analyzer ===
Scan errors: 0
Parse errors: 0
<CompilationUnitImpl> [0-55]
┗━ <ClassDeclarationImpl> [0-54]
  ┣━ 'class' [0-5]
  ┣━ 'Foo' [6-9]
  ┣━ '{' [10-11]
  ┣━ <FieldDeclarationImpl> [14-24]
  ┃  ┣━ <VariableDeclarationListImpl> [14-23]
  ┃  ┃  ┣━ <NamedTypeImpl> [14-17]
  ┃  ┃  ┃  ┗━ 'int' [14-17]
  ┃  ┃  ┗━ <VariableDeclarationImpl> [18-23]
  ┃  ┃    ┣━ 'i' [18-19]
  ┃  ┃    ┣━ '=' [20-21]
  ┃  ┃    ┗━ <IntegerLiteralImpl> [22-23]
  ┃  ┃      ┗━ '0' [22-23]
  ┃  ┗━ ';' [23-24]
  ┣━ <ConstructorDeclarationImpl> [27-52]
  ┃  ┣━ <SimpleIdentifierImpl> [27-30]
  ┃  ┃  ┗━ 'Foo' [27-30]
  ┃  ┣━ <FormalParameterListImpl> [30-37]
  ┃  ┃  ┣━ '(' [30-31]
  ┃  ┃  ┣━ <SimpleFormalParameterImpl> [31-36]
  ┃  ┃  ┃  ┣━ <NamedTypeImpl> [31-34]
  ┃  ┃  ┃  ┃  ┗━ 'int' [31-34]
  ┃  ┃  ┃  ┗━ 'j' [35-36]
  ┃  ┃  ┗━ ')' [36-37]
  ┃  ┣━ ':' [38-39]
  ┃  ┣━ <ConstructorFieldInitializerImpl> [40-51]
  ┃  ┃  ┣━ <SimpleIdentifierImpl> [40-41]
  ┃  ┃  ┃  ┗━ 'i' [40-41]
  ┃  ┃  ┣━ '=' [42-43]
  ┃  ┃  ┗━ <ThrowExpressionImpl> [44-51]
  ┃  ┃    ┣━ 'throw' [44-49]
  ┃  ┃    ┗━ <IntegerLiteralImpl> [50-51]
  ┃  ┃      ┗━ '0' [50-51]
  ┃  ┗━ <EmptyFunctionBodyImpl> [51-52]
  ┃    ┗━ ';' [51-52]
  ┗━ '}' [53-54]
--------------------------------------------------------------------------------
 === ANTLR ===
Errors of type 1: [[@16,44:48='throw',<78>,3:19] Bad state: , [@16,44:48='throw',<78>,3:19] Bad state: , [@13,38:38=':',<12>,3:13] Bad state: , [@12,36:36=')',<7>,3:11] Bad state: , [@12,36:36=')',<7>,3:11] Bad state: , [@15,42:42='=',<2>,3:17] Bad state: , [@15,42:42='=',<2>,3:17] Bad state: ]
Errors of type 2: []
<startSymbol>
┗━ <libraryDefinition>
  ┣━ <metadata>
  ┣━ <topLevelDefinition>
  ┃  ┗━ <classDeclaration>
  ┃    ┣━ <classModifiers>
  ┃    ┣━ 'class'
  ┃    ┣━ <typeWithParameters>
  ┃    ┃  ┗━ <typeIdentifier>
  ┃    ┃    ┗━ 'Foo'
  ┃    ┣━ '{'
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┃  ┣━ <declaration>
  ┃    ┃  ┃  ┣━ <varOrType>
  ┃    ┃  ┃  ┃  ┗━ <type>
  ┃    ┃  ┃  ┃    ┗━ <typeNotFunction>
  ┃    ┃  ┃  ┃      ┗━ <typeNotVoidNotFunction>
  ┃    ┃  ┃  ┃        ┗━ <typeName>
  ┃    ┃  ┃  ┃          ┗━ <typeIdentifier>
  ┃    ┃  ┃  ┃            ┗━ 'int'
  ┃    ┃  ┃  ┗━ <initializedIdentifierList>
  ┃    ┃  ┃    ┗━ <initializedIdentifier>
  ┃    ┃  ┃      ┣━ <identifier>
  ┃    ┃  ┃      ┃  ┗━ 'i'
  ┃    ┃  ┃      ┣━ '='
  ┃    ┃  ┃      ┗━ <expression>
  ┃    ┃  ┃        ┗━ <conditionalExpression>
  ┃    ┃  ┃          ┗━ <ifNullExpression>
  ┃    ┃  ┃            ┗━ <logicalOrExpression>
  ┃    ┃  ┃              ┗━ <logicalAndExpression>
  ┃    ┃  ┃                ┗━ <equalityExpression>
  ┃    ┃  ┃                  ┗━ <relationalExpression>
  ┃    ┃  ┃                    ┗━ <bitwiseOrExpression>
  ┃    ┃  ┃                      ┗━ <bitwiseXorExpression>
  ┃    ┃  ┃                        ┗━ <bitwiseAndExpression>
  ┃    ┃  ┃                          ┗━ <shiftExpression>
  ┃    ┃  ┃                            ┗━ <additiveExpression>
  ┃    ┃  ┃                              ┗━ <multiplicativeExpression>
  ┃    ┃  ┃                                ┗━ <unaryExpression>
  ┃    ┃  ┃                                  ┗━ <postfixExpression>
  ┃    ┃  ┃                                    ┗━ <primary>
  ┃    ┃  ┃                                      ┗━ <literal>
  ┃    ┃  ┃                                        ┗━ <numericLiteral>
  ┃    ┃  ┃                                          ┗━ '0'
  ┃    ┃  ┗━ ';'
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┃  ┗━ 'Foo'
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┃  ┗━ '('
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┃  ┗━ 'int'
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┃  ┣━ 'j'
  ┃    ┃  ┣━ ')'
  ┃    ┃  ┗━ ':'
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┃  ┣━ 'i'
  ┃    ┃  ┣━ '='
  ┃    ┃  ┣━ 'throw'
  ┃    ┃  ┣━ '0'
  ┃    ┃  ┗━ ';'
  ┃    ┗━ '}'
  ┗━ '<EOF>'

Assignment expressions are also supported by the implementation (it even supports cascades), but not by the spec:

class Foo {
  int i = 0;
  Foo(int j) : i = j *= 0;
}
 === Analyzer ===
Scan errors: 0
Parse errors: 0
<CompilationUnitImpl> [0-54]
┗━ <ClassDeclarationImpl> [0-53]
  ┣━ 'class' [0-5]
  ┣━ 'Foo' [6-9]
  ┣━ '{' [10-11]
  ┣━ <FieldDeclarationImpl> [14-24]
  ┃  ┣━ <VariableDeclarationListImpl> [14-23]
  ┃  ┃  ┣━ <NamedTypeImpl> [14-17]
  ┃  ┃  ┃  ┗━ 'int' [14-17]
  ┃  ┃  ┗━ <VariableDeclarationImpl> [18-23]
  ┃  ┃    ┣━ 'i' [18-19]
  ┃  ┃    ┣━ '=' [20-21]
  ┃  ┃    ┗━ <IntegerLiteralImpl> [22-23]
  ┃  ┃      ┗━ '0' [22-23]
  ┃  ┗━ ';' [23-24]
  ┣━ <ConstructorDeclarationImpl> [27-51]
  ┃  ┣━ <SimpleIdentifierImpl> [27-30]
  ┃  ┃  ┗━ 'Foo' [27-30]
  ┃  ┣━ <FormalParameterListImpl> [30-37]
  ┃  ┃  ┣━ '(' [30-31]
  ┃  ┃  ┣━ <SimpleFormalParameterImpl> [31-36]
  ┃  ┃  ┃  ┣━ <NamedTypeImpl> [31-34]
  ┃  ┃  ┃  ┃  ┗━ 'int' [31-34]
  ┃  ┃  ┃  ┗━ 'j' [35-36]
  ┃  ┃  ┗━ ')' [36-37]
  ┃  ┣━ ':' [38-39]
  ┃  ┣━ <ConstructorFieldInitializerImpl> [40-50]
  ┃  ┃  ┣━ <SimpleIdentifierImpl> [40-41]
  ┃  ┃  ┃  ┗━ 'i' [40-41]
  ┃  ┃  ┣━ '=' [42-43]
  ┃  ┃  ┗━ <AssignmentExpressionImpl> [44-50]
  ┃  ┃    ┣━ <SimpleIdentifierImpl> [44-45]
  ┃  ┃    ┃  ┗━ 'j' [44-45]
  ┃  ┃    ┣━ '*=' [46-48]
  ┃  ┃    ┗━ <IntegerLiteralImpl> [49-50]
  ┃  ┃      ┗━ '0' [49-50]
  ┃  ┗━ <EmptyFunctionBodyImpl> [50-51]
  ┃    ┗━ ';' [50-51]
  ┗━ '}' [52-53]
--------------------------------------------------------------------------------
 === ANTLR ===
Errors of type 1: [[@17,46:47='*=',<22>,3:21] Bad state: , [@17,46:47='*=',<22>,3:21] Bad state: , [@13,38:38=':',<12>,3:13] Bad state: , [@12,36:36=')',<7>,3:11] Bad state: , [@12,36:36=')',<7>,3:11] Bad state: , [@15,42:42='=',<2>,3:17] Bad state: , [@15,42:42='=',<2>,3:17] Bad state: , [@17,46:47='*=',<22>,3:21] Bad state: , [@17,46:47='*=',<22>,3:21] Bad state: ]
Errors of type 2: []
<startSymbol>
┗━ <libraryDefinition>
  ┣━ <metadata>
  ┣━ <topLevelDefinition>
  ┃  ┗━ <classDeclaration>
  ┃    ┣━ <classModifiers>
  ┃    ┣━ 'class'
  ┃    ┣━ <typeWithParameters>
  ┃    ┃  ┗━ <typeIdentifier>
  ┃    ┃    ┗━ 'Foo'
  ┃    ┣━ '{'
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┃  ┣━ <declaration>
  ┃    ┃  ┃  ┣━ <varOrType>
  ┃    ┃  ┃  ┃  ┗━ <type>
  ┃    ┃  ┃  ┃    ┗━ <typeNotFunction>
  ┃    ┃  ┃  ┃      ┗━ <typeNotVoidNotFunction>
  ┃    ┃  ┃  ┃        ┗━ <typeName>
  ┃    ┃  ┃  ┃          ┗━ <typeIdentifier>
  ┃    ┃  ┃  ┃            ┗━ 'int'
  ┃    ┃  ┃  ┗━ <initializedIdentifierList>
  ┃    ┃  ┃    ┗━ <initializedIdentifier>
  ┃    ┃  ┃      ┣━ <identifier>
  ┃    ┃  ┃      ┃  ┗━ 'i'
  ┃    ┃  ┃      ┣━ '='
  ┃    ┃  ┃      ┗━ <expression>
  ┃    ┃  ┃        ┗━ <conditionalExpression>
  ┃    ┃  ┃          ┗━ <ifNullExpression>
  ┃    ┃  ┃            ┗━ <logicalOrExpression>
  ┃    ┃  ┃              ┗━ <logicalAndExpression>
  ┃    ┃  ┃                ┗━ <equalityExpression>
  ┃    ┃  ┃                  ┗━ <relationalExpression>
  ┃    ┃  ┃                    ┗━ <bitwiseOrExpression>
  ┃    ┃  ┃                      ┗━ <bitwiseXorExpression>
  ┃    ┃  ┃                        ┗━ <bitwiseAndExpression>
  ┃    ┃  ┃                          ┗━ <shiftExpression>
  ┃    ┃  ┃                            ┗━ <additiveExpression>
  ┃    ┃  ┃                              ┗━ <multiplicativeExpression>
  ┃    ┃  ┃                                ┗━ <unaryExpression>
  ┃    ┃  ┃                                  ┗━ <postfixExpression>
  ┃    ┃  ┃                                    ┗━ <primary>
  ┃    ┃  ┃                                      ┗━ <literal>
  ┃    ┃  ┃                                        ┗━ <numericLiteral>
  ┃    ┃  ┃                                          ┗━ '0'
  ┃    ┃  ┗━ ';'
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┃  ┗━ 'Foo'
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┃  ┗━ '('
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┃  ┗━ 'int'
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┃  ┣━ 'j'
  ┃    ┃  ┣━ ')'
  ┃    ┃  ┗━ ':'
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┃  ┣━ 'i'
  ┃    ┃  ┗━ '='
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┃  ┣━ 'j'
  ┃    ┃  ┣━ '*='
  ┃    ┃  ┣━ '0'
  ┃    ┃  ┗━ ';'
  ┃    ┗━ '}'
  ┗━ '<EOF>'


The spec also supports some expressions that the implementation does not support, see #11509 for that.

@lrhn lrhn added the area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). label Dec 7, 2023
@eernstg
Copy link
Member

eernstg commented Dec 8, 2023

This is something that we should just fix by changing the specification. https://dart-review.googlesource.com/340620 updates Dart.g.

@modulovalue
Copy link
Contributor Author

modulovalue commented Dec 8, 2023

@eernstg The implementation does not support cascades with throw expressions in constructor initializer expressions.

class Foo {
  final a;
  Foo() : throw 0..id;
}
 === Analyzer ===
Scan errors: 0
Parse errors: 6
file(44..45): A function body must be provided.
file(44..45): Operator declarations must be preceded by the keyword 'operator'.
file(44..45): The string '..' isn't a user-definable operator.
file(44..45): Methods must have an explicit list of parameters.
file(46..47): A function body must be provided.
file(46..47): Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
<CompilationUnitImpl> [0-52]
┗━ <ClassDeclarationImpl> [0-51]
  ┣━ 'class' [0-5]
  ┣━ 'Foo' [6-9]
  ┣━ '{' [10-11]
  ┣━ <FieldDeclarationImpl> [14-22]
  ┃  ┣━ <VariableDeclarationListImpl> [14-21]
  ┃  ┃  ┣━ 'final' [14-19]
  ┃  ┃  ┗━ <VariableDeclarationImpl> [20-21]
  ┃  ┃    ┗━ 'a' [20-21]
  ┃  ┗━ ';' [21-22]
  ┣━ <ConstructorDeclarationImpl> [25-44]
  ┃  ┣━ <SimpleIdentifierImpl> [25-28]
  ┃  ┃  ┗━ 'Foo' [25-28]
  ┃  ┣━ <FormalParameterListImpl> [28-30]
  ┃  ┃  ┣━ '(' [28-29]
  ┃  ┃  ┗━ ')' [29-30]
  ┃  ┣━ ':' [31-32]
  ┃  ┣━ <ConstructorFieldInitializerImpl> [33-44]
  ┃  ┃  ┣━ <SimpleIdentifierImpl> [33-34]
  ┃  ┃  ┃  ┗━ 'a' [33-34]
  ┃  ┃  ┣━ '=' [35-36]
  ┃  ┃  ┗━ <ThrowExpressionImpl> [37-44]
  ┃  ┃    ┣━ 'throw' [37-42]
  ┃  ┃    ┗━ <IntegerLiteralImpl> [43-44]
  ┃  ┃      ┗━ '0' [43-44]
  ┃  ┗━ <BlockFunctionBodyImpl> [44-44]
  ┃    ┗━ <BlockImpl> [44-44]
  ┃      ┣━ '{' [44-44]
  ┃      ┗━ '}' [44-44]
  ┣━ <MethodDeclarationImpl> [44-46]
  ┃  ┣━ 'operator' [44-44]
  ┃  ┣━ '..' [44-46]
  ┃  ┣━ <FormalParameterListImpl> [46-46]
  ┃  ┃  ┣━ '(' [46-46]
  ┃  ┃  ┗━ ')' [46-46]
  ┃  ┗━ <BlockFunctionBodyImpl> [46-46]
  ┃    ┗━ <BlockImpl> [46-46]
  ┃      ┣━ '{' [46-46]
  ┃      ┗━ '}' [46-46]
  ┣━ <FieldDeclarationImpl> [46-49]
  ┃  ┣━ <VariableDeclarationListImpl> [46-48]
  ┃  ┃  ┗━ <VariableDeclarationImpl> [46-48]
  ┃  ┃    ┗━ 'id' [46-48]
  ┃  ┗━ ';' [48-49]
  ┗━ '}' [50-51]

@modulovalue
Copy link
Contributor Author

@eernstg The proposed changes also add support for, e.g.:

class Foo {
  final a;
  Foo() : a = a = () {};
}

Which is rejected by the implementation:

 === Analyzer ===
Scan errors: 0
Parse errors: 1
file(46..46): Expected a class member.
<CompilationUnitImpl> [0-50]
┗━ <ClassDeclarationImpl> [0-49]
  ┣━ 'class' [0-5]
  ┣━ 'Foo' [6-9]
  ┣━ '{' [10-11]
  ┣━ <FieldDeclarationImpl> [14-22]
  ┃  ┣━ <VariableDeclarationListImpl> [14-21]
  ┃  ┃  ┣━ 'final' [14-19]
  ┃  ┃  ┗━ <VariableDeclarationImpl> [20-21]
  ┃  ┃    ┗━ 'a' [20-21]
  ┃  ┗━ ';' [21-22]
  ┣━ <ConstructorDeclarationImpl> [25-46]
  ┃  ┣━ <SimpleIdentifierImpl> [25-28]
  ┃  ┃  ┗━ 'Foo' [25-28]
  ┃  ┣━ <FormalParameterListImpl> [28-30]
  ┃  ┃  ┣━ '(' [28-29]
  ┃  ┃  ┗━ ')' [29-30]
  ┃  ┣━ ':' [31-32]
  ┃  ┣━ <ConstructorFieldInitializerImpl> [33-43]
  ┃  ┃  ┣━ <SimpleIdentifierImpl> [33-34]
  ┃  ┃  ┃  ┗━ 'a' [33-34]
  ┃  ┃  ┣━ '=' [35-36]
  ┃  ┃  ┗━ <AssignmentExpressionImpl> [37-43]
  ┃  ┃    ┣━ <SimpleIdentifierImpl> [37-38]
  ┃  ┃    ┃  ┗━ 'a' [37-38]
  ┃  ┃    ┣━ '=' [39-40]
  ┃  ┃    ┗━ <RecordLiteralImpl> [41-43]
  ┃  ┃      ┣━ '(' [41-42]
  ┃  ┃      ┗━ ')' [42-43]
  ┃  ┗━ <BlockFunctionBodyImpl> [44-46]
  ┃    ┗━ <BlockImpl> [44-46]
  ┃      ┣━ '{' [44-45]
  ┃      ┗━ '}' [45-46]
  ┗━ '}' [48-49]
--------------------------------------------------------------------------------
 === ANTLR ===
Errors of type 1: []
Errors of type 2: []
<startSymbol>
┗━ <libraryDefinition>
  ┣━ <metadata>
  ┣━ <topLevelDefinition>
  ┃  ┗━ <classDeclaration>
  ┃    ┣━ <classModifiers>
  ┃    ┣━ 'class'
  ┃    ┣━ <typeWithParameters>
  ┃    ┃  ┗━ <typeIdentifier>
  ┃    ┃    ┗━ 'Foo'
  ┃    ┣━ '{'
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┃  ┣━ <declaration>
  ┃    ┃  ┃  ┣━ 'final'
  ┃    ┃  ┃  ┗━ <initializedIdentifierList>
  ┃    ┃  ┃    ┗━ <initializedIdentifier>
  ┃    ┃  ┃      ┗━ <identifier>
  ┃    ┃  ┃        ┗━ 'a'
  ┃    ┃  ┗━ ';'
  ┃    ┣━ <metadata>
  ┃    ┣━ <classMemberDeclaration>
  ┃    ┃  ┣━ <declaration>
  ┃    ┃  ┃  ┣━ <constructorSignature>
  ┃    ┃  ┃  ┃  ┣━ <constructorName>
  ┃    ┃  ┃  ┃  ┃  ┗━ <typeIdentifier>
  ┃    ┃  ┃  ┃  ┃    ┗━ 'Foo'
  ┃    ┃  ┃  ┃  ┗━ <formalParameterList>
  ┃    ┃  ┃  ┃    ┣━ '('
  ┃    ┃  ┃  ┃    ┗━ ')'
  ┃    ┃  ┃  ┗━ <initializers>
  ┃    ┃  ┃    ┣━ ':'
  ┃    ┃  ┃    ┗━ <initializerListEntry>
  ┃    ┃  ┃      ┗━ <fieldInitializer>
  ┃    ┃  ┃        ┣━ <identifier>
  ┃    ┃  ┃        ┃  ┗━ 'a'
  ┃    ┃  ┃        ┣━ '='
  ┃    ┃  ┃        ┗━ <initializerExpression>
  ┃    ┃  ┃          ┣━ <assignableExpression>
  ┃    ┃  ┃          ┃  ┗━ <identifier>
  ┃    ┃  ┃          ┃    ┗━ 'a'
  ┃    ┃  ┃          ┣━ <assignmentOperator>
  ┃    ┃  ┃          ┃  ┗━ '='
  ┃    ┃  ┃          ┗━ <expression>
  ┃    ┃  ┃            ┗━ <conditionalExpression>
  ┃    ┃  ┃              ┗━ <ifNullExpression>
  ┃    ┃  ┃                ┗━ <logicalOrExpression>
  ┃    ┃  ┃                  ┗━ <logicalAndExpression>
  ┃    ┃  ┃                    ┗━ <equalityExpression>
  ┃    ┃  ┃                      ┗━ <relationalExpression>
  ┃    ┃  ┃                        ┗━ <bitwiseOrExpression>
  ┃    ┃  ┃                          ┗━ <bitwiseXorExpression>
  ┃    ┃  ┃                            ┗━ <bitwiseAndExpression>
  ┃    ┃  ┃                              ┗━ <shiftExpression>
  ┃    ┃  ┃                                ┗━ <additiveExpression>
  ┃    ┃  ┃                                  ┗━ <multiplicativeExpression>
  ┃    ┃  ┃                                    ┗━ <unaryExpression>
  ┃    ┃  ┃                                      ┗━ <postfixExpression>
  ┃    ┃  ┃                                        ┗━ <primary>
  ┃    ┃  ┃                                          ┗━ <functionPrimary>
  ┃    ┃  ┃                                            ┣━ <formalParameterPart>
  ┃    ┃  ┃                                            ┃  ┗━ <formalParameterList>
  ┃    ┃  ┃                                            ┃    ┣━ '('
  ┃    ┃  ┃                                            ┃    ┗━ ')'
  ┃    ┃  ┃                                            ┗━ <functionPrimaryBody>
  ┃    ┃  ┃                                              ┗━ <block>
  ┃    ┃  ┃                                                ┣━ '{'
  ┃    ┃  ┃                                                ┣━ <statements>
  ┃    ┃  ┃                                                ┗━ '}'
  ┃    ┃  ┗━ ';'
  ┃    ┗━ '}'
  ┗━ '<EOF>'

@modulovalue

This comment was marked as duplicate.

@eernstg
Copy link
Member

eernstg commented Dec 8, 2023

The cascade issue is the topic of #54284.

@eernstg
Copy link
Member

eernstg commented Dec 8, 2023

About this one:

class Foo {
  final a;
  Foo() : a = a = () {};
}

The proposed specification in dart-lang/language#3503 clearly needs to be refined.

I'm asking for further information about how the parser actually works in #54284. When this has been clarified we should be in a better position to find a way to (1) write down what it does, and/or (2) ask for adjustments of the implemented behavior (in case it's not what we want).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language).
Projects
None yet
Development

No branches or pull requests

3 participants