Skip to content

Compiler crash when using collection-if pattern. #51379

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

Closed
mmcdon20 opened this issue Feb 12, 2023 · 3 comments
Closed

Compiler crash when using collection-if pattern. #51379

mmcdon20 opened this issue Feb 12, 2023 · 3 comments
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.

Comments

@mmcdon20
Copy link

mmcdon20 commented Feb 12, 2023

At the request of @asashour, posting this as a separate issue.

Compiler crash when using collection-if pattern.

Using Dart SDK version: 3.0.0-229.0.dev (dev) (Fri Feb 10 20:38:38 2023 -0800) on "windows_x64".

compiled with dart --enable-experiment=records,patterns bin/example.dart

void main() {
  print(example([[1], [2], [3]], 2));
}

List<int> example(List<List<int>> lists, int n) => 
    [for (var list in lists) if (list case [var v] when v == n) v];
Crash when compiling file:///C:/Users/mmcdo/Documents/projects/project/bin/example.dart at character offset 
105:
type 'Scope' is not a subtype of type 'Token' in type cast

#0      BodyBuilder.endIfControlFlow (package:front_end/src/fasta/kernel/body_builder.dart:6514:27)
#1      IfComplete.parse (package:_fe_analyzer_shared/src/parser/literal_entry_info_impl.dart:212:23)
#2      Nested.parse (package:_fe_analyzer_shared/src/parser/literal_entry_info_impl.dart:303:58)
#3      Parser.parseLiteralListSuffix (package:_fe_analyzer_shared/src/parser/parser_impl.dart:6577:24)
#4      Parser.parsePrimary (package:_fe_analyzer_shared/src/parser/parser_impl.dart:6301:14)
#5      Parser.parseUnaryExpression (package:_fe_analyzer_shared/src/parser/parser_impl.dart:6116:12)
#6      Parser.parsePrecedenceExpression (package:_fe_analyzer_shared/src/parser/parser_impl.dart:5627:13)
#7      Parser.parseExpression (package:_fe_analyzer_shared/src/parser/parser_impl.dart:5567:15)
#8      Parser.parseExpressionFunctionBody (package:_fe_analyzer_shared/src/parser/parser_impl.dart:5240:13)
#9      Parser.parseFunctionBody (package:_fe_analyzer_shared/src/parser/parser_impl.dart:5167:14)
#10     DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:1120:14)
#11     DietListener.endTopLevelMethod (package:front_end/src/fasta/source/diet_listener.dart:376:5)
#12     Parser.parseTopLevelMethod (package:_fe_analyzer_shared/src/parser/parser_impl.dart:3682:14)
#13     Parser.parseTopLevelMemberImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:3424:14)
#14     Parser.parseTopLevelDeclarationImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:606:14)
#15     Parser.parseUnit (package:_fe_analyzer_shared/src/parser/parser_impl.dart:403:15)
#16     SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:1267:12)
<asynchronous suspension>
#17     SourceLoader.buildBodies (package:front_end/src/fasta/source/source_loader.dart:676:7)
<asynchronous suspension>
#18     KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:611:7)
<asynchronous suspension>
#19     withCrashReporting (package:front_end/src/fasta/crash.dart:136:12)
<asynchronous suspension>
#20     _buildInternal (package:front_end/src/kernel_generator_impl.dart:206:19)
<asynchronous suspension>
#21     withCrashReporting (package:front_end/src/fasta/crash.dart:136:12)
<asynchronous suspension>
#22     generateKernel.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:48:12)
<asynchronous suspension>
#23     generateKernel (package:front_end/src/kernel_generator_impl.dart:47:10)
<asynchronous suspension>
#24     kernelForModule (package:front_end/src/api_prototype/kernel_generator.dart:100:11)
<asynchronous suspension>
#25     SingleShotCompilerWrapper.compileInternal (file:///C:/b/s/w/ir/x/w/sdk/pkg/vm/bin/kernel_service.dart:407:11)
<asynchronous suspension>
#26     Compiler.compile.<anonymous closure> (file:///C:/b/s/w/ir/x/w/sdk/pkg/vm/bin/kernel_service.dart:215:45)
<asynchronous suspension>
#27     _processLoadRequest (file:///C:/b/s/w/ir/x/w/sdk/pkg/vm/bin/kernel_service.dart:889:37)
<asynchronous suspension>

Originally posted by @mmcdon20 in #51376 (comment)

@asashour
Copy link
Contributor

Seems to be a duplicate of #51327

@mraleph mraleph added the legacy-area-front-end Legacy: Use area-dart-model instead. label Feb 13, 2023
@mmcdon20
Copy link
Author

@asashour It appears to be the same error message, so I will close this issue.

@mmcdon20
Copy link
Author

No longer seeing this error on latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.
Projects
None yet
Development

No branches or pull requests

3 participants