Skip to content

[dart2js] crash when using records with null-assertions #52276

Closed
@sigmundch

Description

@sigmundch

This program crashes during SSA:

main() => foo((1, 2));
foo((int, int) p) {
  print(p);
}

With the following stack when run as: dart compile js --null-assertions repro.dart

The compiler crashed: UnimplementedError: isNonNullableIfSound (int,int)
#0      DartTypes.isNonNullableIfSound (package:compiler/src/elements/types.dart:2423:5)
#1      KernelSsaGraphBuilder._potentiallyAssertNotNull (package:compiler/src/ssa/builder.dart:1615:20)
#2      KernelSsaGraphBuilder._potentiallyCheckInlinedParameterTypes.<anonymous closure> (package:compiler/src/ssa/builder.dart:6752:11)
#3      forEachOrderedParameter.handleParameter (package:compiler/src/js_model/element_map.dart:602:6)
#4      forEachOrderedParameterByFunctionNode (package:compiler/src/js_model/element_map.dart:574:6)
#5      forEachOrderedParameter (package:compiler/src/js_model/element_map.dart:610:9)
#6      KernelSsaGraphBuilder._potentiallyCheckInlinedParameterTypes (package:compiler/src/ssa/builder.dart:6738:5)
#7      KernelSsaGraphBuilder._visitInlinedFunction (package:compiler/src/ssa/builder.dart:6687:5)
#8      KernelSsaGraphBuilder._doInline (package:compiler/src/ssa/builder.dart:6682:5)
#9      KernelSsaGraphBuilder._doTryInlineMethod.doInlining.<anonymous closure> (package:compiler/src/ssa/builder.dart:6375:11)
#10     KernelSsaGraphBuilder._inlinedFrom.<anonymous closure> (package:compiler/src/ssa/builder.dart:962:21)
#11     DiagnosticReporter.withCurrentElement (package:compiler/src/diagnostics/diagnostic_listener.dart:142:15)
#12     KernelSsaGraphBuilder._inlinedFrom (package:compiler/src/ssa/builder.dart:960:14)
#13     KernelSsaGraphBuilder._doTryInlineMethod.doInlining (package:compiler/src/ssa/builder.dart:6370:7)
#14     KernelSsaGraphBuilder._doTryInlineMethod (package:compiler/src/ssa/builder.dart:6382:7)
#15     KernelSsaGraphBuilder._tryInlineMethod (package:compiler/src/ssa/builder.dart:6135:21)
#16     KernelSsaGraphBuilder._pushStaticInvocation (package:compiler/src/ssa/builder.dart:5321:9)
#17     KernelSsaGraphBuilder.visitStaticInvocation (package:compiler/src/ssa/builder.dart:4248:7)
#18     StaticInvocation.accept (package:kernel/ast.dart:7041:44)

Note that --null-assertions this is only valuable with mixed-mode programs using unsound null safety, so this doesn't affect users of Dart 3 and the fix doesn't need to be cherry-picked.

It does reveal that our compiler still allows using this flag with sound programs, which is unnecessary and may require additional cleanup.

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work onarea-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-dart2js

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions