Skip to content

dart2js with package js crash #26322

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
sircco opened this issue Apr 23, 2016 · 5 comments
Closed

dart2js with package js crash #26322

sircco opened this issue Apr 23, 2016 · 5 comments

Comments

@sircco
Copy link

sircco commented Apr 23, 2016

import 'package:js/js.dart';

main() {
        foo = allowInterop(() {
                        print("nja nja naj");
                        }
                );
}

@JS
        external set foo(Function f);


a@LinL460:/tmp/jstest/web$ dart2js main.dart -o main.dart.js
main.dart:12:2:
Error: A metadata annotation must be either a reference to a compile-time constant variable or a call to a constant constructor.
Try using a different constant value or referencing it through a constant variable.
@js
^^
main.dart:12:1:
Internal Error: Invalid @js(...) annotation.
@js
^^^
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,

Ubuntu 16.04

  • the Dart SDK build number (1.15.0), and

1.15.0

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

The compiler crashed: Internal Error: Invalid @js(...) annotation.
#0 _CompilerDiagnosticReporter.internalError (file:///tmp/tmpla4aZL/dart-1.15.0/dart/pkg/compiler/lib/src/compiler.dart:1963)
#1 JsInteropAnnotationHandler.validate (file:///tmp/tmpla4aZL/dart-1.15.0/dart/pkg/compiler/lib/src/patch_parser.dart:514)
#2 EagerAnnotationHandler.checkAnnotation. (file:///tmp/tmpla4aZL/dart-1.15.0/dart/pkg/compiler/lib/src/patch_parser.dart:431)
#3 _CompilerDiagnosticReporter.withCurrentElement (file:///tmp/tmpla4aZL/dart-1.15.0/dart/pkg/compiler/lib/src/compiler.dart:1753)
#4 ResolutionEnqueuer.emptyDeferredTaskQueue (file:///tmp/tmpla4aZL/dart-1.15.0/dart/pkg/compiler/lib/src/enqueue.dart:885)
#5 ResolutionEnqueuer.onQueueEmpty (file:///tmp/tmpla4aZL/dart-1.15.0/dart/pkg/compiler/lib/src/enqueue.dart:878)
#6 Enqueuer.forEach (file:///tmp/tmpla4aZL/dart-1.15.0/dart/pkg/compiler/lib/src/enqueue.dart:708)
#7 Compiler.emptyQueue (file:///tmp/tmpla4aZL/dart-1.15.0/dart/pkg/compiler/lib/src/compiler.dart:1117)
#8 Compiler.processQueue (file:///tmp/tmpla4aZL/dart-1.15.0/dart/pkg/compiler/lib/src/compiler.dart:1145)
#9 Compiler.compileLoadedLibraries (file:///tmp/tmpla4aZL/dart-1.15.0/dart/pkg/compiler/lib/src/compiler.dart:1013)
#10 Compiler.runInternal. (file:///tmp/tmpla4aZL/dart-1.15.0/dart/pkg/compiler/lib/src/compiler.dart:884)
#11 _RootZone.runUnary (dart:async/zone.dart:1137)
#12 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:551)
#13 _Future._propagateToListeners (dart:async/future_impl.dart:637)
#14 _Future._completeWithValue (dart:async/future_impl.dart:424)
#15 _Future._asyncComplete. (dart:async/future_impl.dart:479)
#16 _microtaskLoop (dart:async/schedule_microtask.dart:41)
#17 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#18 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:96)
#19 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:149)

@sigmundch
Copy link
Member

In case you haven't figured it out already, it appears that the issue is that you need to add () to your annotation (@JS() instead of @JS). The first error message is trying to indicate this, but in my opinion is not that obvious what to do about it. We also should not crash on this regardless.

@sigmundch sigmundch added web-dart2js web-js-interop Issues that impact all js interop labels Apr 25, 2016
@kevmoo kevmoo closed this as completed Apr 26, 2016
@kevmoo
Copy link
Member

kevmoo commented Apr 26, 2016

Oops. Reopening to track the better error message

@kevmoo kevmoo reopened this Apr 26, 2016
@jacob314
Copy link
Member

jacob314 commented Jul 7, 2016

This is a general issue with annotations in Dart2JS and Dart. I think the most user friendly solution is to have
@AnyAnnotation
be syntactic sugar for
@AnyAnnotation()
if AnyAnnotation is a class.
This is consistent with how some other languages handle annotations, makes the code users write more terse, and avoids these entirely confusing compile errors altogether.

@jacob314 jacob314 added area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). and removed web-js-interop Issues that impact all js interop labels Jul 7, 2016
@floitschG
Copy link
Contributor

Created #26840 to track your language-change request.
This bug is now about improving the error message.

@floitschG floitschG removed the area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). label Jul 8, 2016
@sigmundch
Copy link
Member

this is handled by the CFE now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants