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

dart2js crashes on "a &&= a" #30340

Closed
rakudrama opened this issue Aug 7, 2017 · 9 comments
Closed

dart2js crashes on "a &&= a" #30340

rakudrama opened this issue Aug 7, 2017 · 9 comments
Assignees
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. front-end-fasta front-end-fasta-recovery web-dart2js

Comments

@rakudrama
Copy link
Member

&&= is not a valid assignment operator.

main() {
  var a = true;
  a &&= a;
}

The VM signals a syntax error

bug1a2c.dart': error: line 3 pos 7: unexpected token '='
  a &&= a;
      ^

dart2js crashes instead of rejecting the syntax error.

> dart2js bug1a2c.dart`

bug1a2c.dart:1:1:
Internal Error: The compiler crashed when compiling this element.
main() {
^^^^^^
The compiler is broken.

When compiling the above element, the compiler crashed. It is not
possible to tell if this is caused by a problem in your program or
not. Regardless, the compiler should not crash.

The Dart team would greatly appreciate if you would take a moment to
report this problem at http://dartbug.com/new.

Please include the following information:

* the name and version of your operating system,

* the Dart SDK build number (build number could not be determined), and

* the entire message you see here (including the full stack trace
  below as well as the source location above).

The compiler crashed: NoSuchMethodError: The getter 'kind' was called on null.
Receiver: null
Tried calling: kind
#0      Object._noSuchMethod (dart:core-patch/object_patch.dart:42)
#1      Object.noSuchMethod (dart:core-patch/object_patch.dart:46)
#2      ResolverVisitor.handleUpdate (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/members.dart:3458:20)
#3      ResolverVisitor.handleLocalUpdate (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/members.dart:2633:31)
#4      ResolverVisitor.handleResolvedSendSet (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/members.dart:2967:14)
#5      ResolverVisitor.handleUnqualifiedSendSet (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/members.dart:3029:14)
#6      ResolverVisitor.visitSendSet (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/members.dart:3516:14)
#7      SendSet.accept (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/tree/nodes.dart:747:38)
#8      CommonResolverVisitor.visit (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/resolution_common.dart:32:54)
#9      ResolverVisitor.visitExpressionStatement (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/members.dart:536:5)
#10     ExpressionStatement.accept (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/tree/nodes.dart:1618:38)
#11     CommonResolverVisitor.visit (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/resolution_common.dart:32:54)
#12     ResolverVisitor.visitNodeList (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/members.dart:3592:7)
#13     NodeList.accept (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/tree/nodes.dart:847:38)
#14     CommonResolverVisitor.visit (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/resolution_common.dart:32:54)
#15     ResolverVisitor.visitIn (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/members.dart:499:31)
#16     ResolverVisitor.visitBlock (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/members.dart:519:5)
#17     Block.accept (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/tree/nodes.dart:903:38)
#18     CommonResolverVisitor.visit (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/resolution_common.dart:32:54)
#19     ResolverTask.resolveMethodElementImplementation.<anonymous closure> (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/resolution.dart:267:17)
#20     CompilerDiagnosticReporter.withCurrentElement (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:1111:15)
#21     ResolverTask.resolveMethodElementImplementation (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/resolution.dart:224:21)
#22     ResolverTask.resolveMethodElement.<anonymous closure> (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/resolution.dart:357:16)
#23     CompilerDiagnosticReporter.withCurrentElement (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:1111:15)
#24     ResolverTask.resolveMethodElement (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/resolution.dart:309:21)
#25     ResolverTask.resolve.<anonymous closure> (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/resolution.dart:105:32)
#26     CompilerTask.measure (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/common/tasks.dart:63:44)
#27     ResolverTask.resolve (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/resolution/resolution.dart:83:12)
#28     CompilerResolution.computeWorldImpact.<anonymous closure>.<anonymous closure> (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:1494:64)
#29     _HashVMBase&MapMixin&&_LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:270)
#30     CompilerResolution.computeWorldImpact.<anonymous closure> (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:1490:32)
#31     CompilerTask.measureSubtask (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/common/tasks.dart:176:35)
#32     CompilerResolution.computeWorldImpact (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:1472:31)
#33     _ResolutionWorkItem.run (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/common/resolution.dart:60:37)
#34     Compiler.emptyQueue.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:752:70)
#35     CompilerTask.measureSubtask (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/common/tasks.dart:176:35)
#36     Compiler.emptyQueue.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:752:32)
#37     CompilerTask.measureSubtask (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/common/tasks.dart:176:35)
#38     Compiler.emptyQueue.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:750:28)
#39     CompilerDiagnosticReporter.withCurrentElement (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:1111:15)
#40     Compiler.emptyQueue.<anonymous closure>.<anonymous closure> (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:748:18)
#41     EnqueuerStrategy.processWorkItem (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/enqueue.dart:511:6)
#42     ResolutionEnqueuer.forEach (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/enqueue.dart:394:20)
#43     Compiler.emptyQueue.<anonymous closure> (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:744:16)
#44     CompilerTask.measureSubtask (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/common/tasks.dart:176:35)
#45     Compiler.emptyQueue (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:743:14)
#46     Compiler.processQueue.<anonymous closure> (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:767:7)
#47     CompilerTask.measureSubtask (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/common/tasks.dart:176:35)
#48     Compiler.processQueue (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:762:14)
#49     Compiler.compileLoadedLibraries.<anonymous closure> (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:572:9)
#50     CompilerTask.measureSubtask (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/common/tasks.dart:176:35)
#51     Compiler.compileLoadedLibraries (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:518:16)
#52     Compiler.runInternal (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:473:5)
<asynchronous suspension>
#53     Compiler.run.<anonymous closure>.<anonymous closure> (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:303:38)
#54     new Future.sync (dart:async/future.dart:222)
#55     Compiler.run.<anonymous closure> (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:303:20)
#56     CompilerTask.measureSubtask (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/common/tasks.dart:176:35)
#57     Compiler.run (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/compiler.dart:300:41)
#58     CompilerImpl.run.<anonymous closure>.<anonymous closure> (file:///usr/local/google/home/sra/Dart/sdk/pkg/compiler/lib/src/apiimpl.dart:265:25)
#59     _RootZone.runUnary (dart:async/zone.dart:1371)
#60     _FutureListener.handleValue (dart:async/future_impl.dart:129)
#61     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:636)
#62     _Future._propagateToListeners (dart:async/future_impl.dart:665)
#63     _Future._addListener.<anonymous closure> (dart:async/future_impl.dart:343)
#64     _microtaskLoop (dart:async/schedule_microtask.dart:41)
#65     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#66     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:99)
#67     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:152)

@peter-ahe-google
Copy link
Contributor

If you assign this to area-fasta, I'll fix it in the parser :-)

@rakudrama
Copy link
Member Author

Also crashes in fasta:

bug1a2c.dart:3:5: Internal problem: Unhandled &&= in handleAssignment.
  a &&= a;
    ^
#0      internalProblem (package:front_end/src/fasta/problems.dart:29:3)
#1      unhandled (package:front_end/src/fasta/problems.dart:41:10)
#2      DelayedAssignment.handleAssignment (package:front_end/src/fasta/kernel/body_builder.dart:3513:14)
#3      DelayedAssignment.buildForEffect (package:front_end/src/fasta/kernel/body_builder.dart:3465:12)
#4      BodyBuilder.toEffect (package:front_end/src/fasta/kernel/body_builder.dart:240:44)
#5      BodyBuilder.popForEffect (package:front_end/src/fasta/kernel/body_builder.dart:217:32)
#6      BodyBuilder.endExpressionStatement (package:front_end/src/fasta/kernel/body_builder.dart:688:40)
#7      Parser.parseExpressionStatement (package:front_end/src/fasta/parser/parser.dart:2744:14)
#8      Parser.parseType (package:front_end/src/fasta/parser/parser.dart:1265:16)
#9      Parser.parseExpressionStatementOrDeclaration (package:front_end/src/fasta/parser/parser.dart:2708:12)
#10     Parser.parseStatementX (package:front_end/src/fasta/parser/parser.dart:2611:14)
#11     Parser.parseStatement (package:front_end/src/fasta/parser/parser.dart:2603:20)
#12     Parser.parseFunctionBody (package:front_end/src/fasta/parser/parser.dart:2533:15)
#13     DietListener.parseFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:585:14)
#14     DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:451:5)
#15     DietListener.endTopLevelMethod (package:front_end/src/fasta/source/diet_listener.dart:230:5)
#16     Parser.parseTopLevelMethod (package:front_end/src/fasta/parser/parser.dart:1658:14)
#17     Parser.parseTopLevelMember (package:front_end/src/fasta/parser/parser.dart:1563:11)
#18     Parser._parseTopLevelDeclaration (package:front_end/src/fasta/parser/parser.dart:265:14)
#19     Parser.parseTopLevelDeclaration (package:front_end/src/fasta/parser/parser.dart:237:13)
#20     Parser.parseUnit (package:front_end/src/fasta/parser/parser.dart:229:15)

@peter-ahe-google
Copy link
Contributor

This was caused by CL 2895803002 or CL 2903063003.

Moving forward, we should ensure that all new features added to the shared front-end have a corresponding test in tests/language (or whatever the new location is).

In my opinion, we shouldn't be adding experimental features to the shared front-end, and we should remove them from the analyzer instead.

@floitschG
Copy link
Contributor

This feature is not really experimental. It is supposed to get implemented everywhere:
#26996

@peter-ahe-google
Copy link
Contributor

@floitschG could you elaborate on how this feature isn't experimental and how this is implied by the existence of issue #26996?

@danrubel
Copy link

danrubel commented Aug 8, 2017

@peter-ahe-google the quickest short term fix is to put lazy assignments behind a flag again (partially revert CL 2903063003). I'll start work on that tomorrow unless I hear otherwise.

@peter-ahe-google
Copy link
Contributor

I'd like to avoid having flags. Flags don't solve the issue (which is lack of testing), and creates more problems (increasing the number of test configurations we must test, and creating horrible error message).

Adding a flag doesn't relieve us from having to test code, and for dart2js, that would mean doubling the number of build bots.

The real issue here is lack of testing. When we implement a new feature in a shared component, we need to also write tests that can exercise all of our tools. There's nothing wrong with writing an analyzer unit test, but we must also write shared tests.

Alternatives are

  • Revert CL 2903063003, and double the number of build bots.
  • Revert CL 2895803002, and rework it with a shared test.
  • Add a shared test and do the minimal work to make sure that fasta and dart2js don't crash (change the token type of these compound assignments).
  • Remove this feature until we've switch to kernel.

As far as I'm concerned, each new feature that is implemented before we switch to the shared front-end is delaying the switch to the shared front-end, and will actually be counter productive towards getting these features delivered to our customers. For this reason, the above order of alternatives go from the first being my least preferred to the last being my most preferred.

@sigmundch sigmundch added the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label Oct 4, 2017
@peter-ahe-google
Copy link
Contributor

@danrubel ping

@danrubel
Copy link

I'll try to dig into this next week.

@whesse whesse closed this as completed in 2b681b2 Oct 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. front-end-fasta front-end-fasta-recovery web-dart2js
Projects
None yet
Development

No branches or pull requests

5 participants