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

Fasta crash on setter with no parameters #31069

Closed
askeksa-google opened this Issue Oct 11, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@askeksa-google
Contributor

askeksa-google commented Oct 11, 2017

Compiling a setter with no parameters:

class C {
  static void set setter() { }
}

main() {
  C.setter = null;
}

crashes with this exception:

Unhandled exception:
RangeError (index): Invalid value: Valid value range is empty: 0
#0      List.[] (dart:core-patch/dart:core/growable_array.dart:141)
#1      Procedure.setterType (package:kernel/ast.dart:1392:40)
#2      ShadowStaticAssignment._inferExpression (package:front_end/src/fasta/kernel/kernel_shadow_ast.dart:1599:35)
#3      ShadowTypeInferrer.inferExpression (package:front_end/src/fasta/kernel/kernel_shadow_ast.dart:2022:25)
#4      ShadowExpressionStatement._inferStatement (package:front_end/src/fasta/kernel/kernel_shadow_ast.dart:660:14)
#5      ShadowTypeInferrer.inferStatement (package:front_end/src/fasta/kernel/kernel_shadow_ast.dart:2059:24)
#6      ShadowBlock._inferStatement (package:front_end/src/fasta/kernel/kernel_shadow_ast.dart:186:16)
#7      ShadowTypeInferrer.inferStatement (package:front_end/src/fasta/kernel/kernel_shadow_ast.dart:2059:24)
#8      TypeInferrerImpl.inferFunctionBody (package:front_end/src/fasta/type_inference/type_inferrer.dart:589:5)
#9      BodyBuilder.finishFunction (package:front_end/src/fasta/kernel/body_builder.dart:596:19)
#10     DietListener.listenerFinishFunction (package:front_end/src/fasta/source/diet_listener.dart:581:14)
#11     DietListener.parseFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:614:7)
#12     DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:483:5)
#13     DietListener.endTopLevelMethod (package:front_end/src/fasta/source/diet_listener.dart:230:5)
#14     Parser.parseTopLevelMethod (package:front_end/src/fasta/parser/parser.dart:2278:14)
#15     Parser.parseTopLevelMember (package:front_end/src/fasta/parser/parser.dart:2183:11)
#16     Parser.parseTopLevelDeclarationImpl (package:front_end/src/fasta/parser/parser.dart:333:14)
#17     Parser.parseUnit (package:front_end/src/fasta/parser/parser.dart:280:15)
#18     SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:176:14)
<asynchronous suspension>
#19     Loader.buildBodies (package:front_end/src/fasta/loader.dart:125:13)
<asynchronous suspension>
#20     KernelTarget.buildProgram (package:front_end/src/fasta/kernel/kernel_target.dart:281:20)
<asynchronous suspension>
#21     CompileTask.compile (file:///usr/local/google/home/askesc/Drive/dart-sdk/sdk/pkg/front_end/tool/_fasta/entry_points.dart:160:38)
<asynchronous suspension>
#22     compile.<anonymous closure> (file:///usr/local/google/home/askesc/Drive/dart-sdk/sdk/pkg/front_end/tool/_fasta/entry_points.dart:98:25)
<asynchronous suspension>
#23     withGlobalOptions.<anonymous closure> (file:///usr/local/google/home/askesc/Drive/dart-sdk/sdk/pkg/front_end/tool/_fasta/command_line.dart:374:13)
#24     CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:89:33)
#25     _rootRun (dart:async/zone.dart:1124)
#26     _CustomZone.run (dart:async/zone.dart:1021)
#27     runZoned (dart:async/zone.dart:1499)
#28     CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:89:12)
#29     CompilerContext.runWithOptions (package:front_end/src/fasta/compiler_context.dart:96:41)
#30     withGlobalOptions (file:///usr/local/google/home/askesc/Drive/dart-sdk/sdk/pkg/front_end/tool/_fasta/command_line.dart:367:26)
#31     compile (file:///usr/local/google/home/askesc/Drive/dart-sdk/sdk/pkg/front_end/tool/_fasta/entry_points.dart:91:18)
<asynchronous suspension>
#32     compileEntryPoint (file:///usr/local/google/home/askesc/Drive/dart-sdk/sdk/pkg/front_end/tool/_fasta/entry_points.dart:49:11)
<asynchronous suspension>
#33     main (file:///usr/local/google/home/askesc/Drive/dart-sdk/sdk/pkg/front_end/tool/_fasta/compile.dart:7:33)
#34     _startIsolate.<anonymous closure> (dart:isolate-patch/dart:isolate/isolate_patch.dart:275)
#35     _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:163)

@askeksa-google askeksa-google self-assigned this Oct 11, 2017

@whesse whesse closed this in f1b07b2 Oct 16, 2017

whesse pushed a commit that referenced this issue Oct 17, 2017

Reland "Error on setter having not exactly one parameter"
Rewrite setter with invalid parameters into one with one parameter
and a body throwing a compile-time error.

Some analyzer tests fail until we sort out the expected form of the
generated kernel code in situations like this. This is tracked in
#31096

Closes #31069
Original CL: https://dart-review.googlesource.com/13080

Change-Id: I432240c33d6daf0ec6bfe2b73c609ab4762cda8c
Reviewed-on: https://dart-review.googlesource.com/14381
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment