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: --analyze-all breaks code and generally generates different code #17115
Comments
I can repro this on 1.1, hitting another (apparently related) issue on 1.2. On initial investigation it appears the tree-shaking by dart2js is too aggressive. This is falling through the cracks of our unit tests because package:unittest includes dart:mirrors which is essentially turning of tree shaking. Need to eliminate the dart:mirrors import from package:unittest ASAP, in parallel. Set owner to @rakudrama. |
Removed Area-HTML label. |
Correction- tree shaking not caused by mock, but issue still appears related to tree shaking. |
This comment was originally written by cor...@gmail.com For the record, it seems like removing the "--analyze-all" flag seems to fix this problem as well (just as removing it fixes issue #9 @17119). |
--analyze-all causes significant differences in the dart2js output. It will take a concerted effort and extra testing to ensure --analyze-all does not affect the output. It is probably wise, in the short term, to make --analyze-all generate only diagnostics and no JavaScript outputs. Removed the owner. |
Set owner to @floitschG. |
cc @floitschG. |
Fixed by https://codereview.chromium.org/185743002/ which makes --analyze-all imply --analyze-only. Added Fixed label. |
I'm concerned about the selected solution to address this bug: * There is a bug in how type checks are implemented. Disabling tree-shaking during analysis shouldn't cause broken code. Making --analyze-all imply --analyze-only doesn't fix that problem. * Using --analyze-all without --analyze-only is useful. It saves you time as compilation and analysis is done at the same time. * I can construct a program that should behave equivalently by using mirrors (modulo a bug): import 'dart:mirrors'; main() { I'm reopening this bug so my concerns don't drop of the radar, feel free to close it again. Also, I've removed the priority, it was critical which doesn't seem appropriate for my above concerns. Removed Priority-Critical label. |
This issue was originally filed by cor...@gmail.com
Given the following HTML:
<!doctype html>
<html lang="en">
<head>
<script type="application/dart" src="main.dart"></script>
<script type="text/javascript" src="dart.js"></script>
</head>
<body>
<div class="top-menu">
<!-- dynamic content here -->
</div>
</body>
</html>
Given the following Dart code:
import "dart:html";
void main() {
DivElement container = querySelector(".top-menu");
container.appendHtml("Test");
}
When compiling the Dart to JavaScript with the following command:
dart2js --enable-checked-mode --analyze-all --enable-diagnostic-colors -o main.dart.js main.dart
When I visit the HTML page using regular Chrome I get the following error in the output:
Uncaught type 'HtmlElement' is not a subtype of type 'DivElement' js_helper.dart:1058
wrapException js_helper.dart:1058
propertyTypeError js_helper.dart:2380
interceptedTypeCheck js_helper.dart:2422
main html_dart2js.dart:9665
_IsolateContext.eval$1 isolate_helper.dart:247
startRootIsolate isolate_helper.dart:67
(anonymous function) main.dart.js:9515
init.currentScript main.dart.js:9495
(anonymous function) main.dart.js:9509
(anonymous function) html_dart2js.dart:32250
Then I expect no errors and the div-element to contain the text "Test".
What version of the product are you using? On what operating system?
Dart VM version: 1.1.3 (Thu Feb 06 00:06:36 2014) on "windows_ia32"
Windows 8.1, 64bit
Live problem:
https://dl.dropboxusercontent.com/u/8183146/temp/dart/problem1/index.html
The text was updated successfully, but these errors were encountered: