-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
legacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.
Description
Part of #49713.
Consider the following example:
main() {
var r1 = (1, const [42]);
}
When compiled using pkg/front_end/tool/fasta compile --enable-experiment=records --target=none foo.dart
the following kernel is generated:
static method main() → dynamic {
(core::int, core::List<core::int>) r1 = (1, const <core::int>[42]);
}
There is a list literal, not a reference to a constant. Such AST crashes VM-specific lowering transformation which doesn't expect to find ListLiteral
node with isConst
== true:
Unexpected constant ListLiteral node (such nodes should be converted to ConstantExpression): ListLiteral(const <int>[42])
#0 ListLiteralsLowering.transformListLiteral (package:vm/transformations/list_literals_lowering.dart:38:7)
#1 _Lowering.visitListLiteral (package:vm/transformations/lowering.dart:120:33)
#2 ListLiteral.accept (package:kernel/ast.dart:8416:44)
#3 Transformer.transform (package:kernel/visitor.dart:1605:21)
#4 Transformer.transformList (package:kernel/visitor.dart:1640:18)
#5 RecordLiteral.transformChildren (package:kernel/ast.dart:8725:7)
#6 Transformer.defaultTreeNode (package:kernel/visitor.dart:1663:10)
#7 TreeVisitor.defaultExpression (package:kernel/visitor.dart:199:43)
#8 TreeVisitor.visitRecordLiteral (package:kernel/visitor.dart:306:47)
#9 RecordLiteral.accept (package:kernel/ast.dart:8710:44)
#10 Transformer.transform (package:kernel/visitor.dart:1605:21)
#11 VariableDeclaration.transformChildren (package:kernel/ast.dart:11034:23)
#12 Transformer.defaultTreeNode (package:kernel/visitor.dart:1663:10)
#13 TreeVisitor.defaultStatement (package:kernel/visitor.dart:348:41)
#14 TreeVisitor.visitVariableDeclaration (package:kernel/visitor.dart:389:7)
#15 VariableDeclaration.accept (package:kernel/ast.dart:11016:43)
Such ListLiteral
nodes should be converted to ConstantExpression
/ ListConstant
during constant evaluation in CFE.
/cc @johnniwinther
Metadata
Metadata
Assignees
Labels
legacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.