Skip to content

dart2js: try-catch block fails in IE9 and Firefox #3190

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
DartBot opened this issue May 23, 2012 · 11 comments
Closed

dart2js: try-catch block fails in IE9 and Firefox #3190

DartBot opened this issue May 23, 2012 · 11 comments
Assignees

Comments

@DartBot
Copy link

DartBot commented May 23, 2012

This issue was originally filed by @bp74


What steps will reproduce the problem?

import('dart:html');

void main() {
  AudioContext audioContext;
  
  try {
    audioContext = new AudioContext();
  }
  catch(final error) {
    print(error);
  }
}

What is the expected output? What do you see instead?

The code above should throw an exception in IE9 and Firefox, because "AudioContext" is not available in this browsers. Unfortunately the JavaScript generated by dart2js fails with an error. The same code compiled with "frog" works fine. This is the error you get in dart2js:

SCRIPT5007: Unable to get value of the property 'operator$index$1': object is null or undefined

Attached to this issue is a picture of the JavaScript debugger, showing the code where the error happens.

What version of the product are you using? On what operating system?

Dart Editor 7916 32 bit, Windows 7 64 bit


Attachment:
debug.png (56.08 KB)

@DartBot
Copy link
Author

DartBot commented May 23, 2012

This comment was originally written by @bp74


added another picuture showing the call stack.


Attachment:
debug2.png (53.96 KB)

@DartBot
Copy link
Author

DartBot commented May 23, 2012

This comment was originally written by @bp74


addedd another picture showing the line of code causing the problem.


Attachment:
debug3.png (60.17 KB)

@kasperl
Copy link

kasperl commented May 24, 2012

Added Area-Dart2JS, Triaged labels.

@kasperl
Copy link

kasperl commented May 24, 2012

This is an interesting case because we do have an AudioContext class in dart:html. Do you have any insights on this, Stephen? Is the fact that this "works" in frog by design and is it something we've missed in dart2js?


cc @rakudrama.

@rakudrama
Copy link
Member

The code equivalent to unwrapException in the frog runtime is written in JavaScript.
The dart2js version is written in Dart using a few 'JS' forms for low level access.
The difference in behaviour is due to the JavaScript version using [] in JavaScript, where the Dart version uses the Dart indexing operator: jsArguments[0].

Change this to JS('Object', '#[0]', jsArguments) or something similar.

Why does this matter?
I have not verified, but I believe IE is using either a plain object or a special object to hold the arguments.
It is the difference between (in JavaScript)
   ['Foo', 123]
and
   {'length':2, '0':'Foo', '1':123}
The second is not an Array, but it is 'Array-like' - it works most of the time.

I expect we will see more cases like this, e.g. the value of the JavaScript 'arguments' special variable is usually not an instance of Array, so it is copied to an Array with Array.prototype.slice.call(arguments)

@peter-ahe-google
Copy link
Contributor

Thank you, Stephen. As always, very enlightening.


Set owner to @peter-ahe-google.
Added Accepted label.

@kasperl
Copy link

kasperl commented May 25, 2012

CL for review: https://chromiumcodereview.appspot.com/10445032/.

@kasperl
Copy link

kasperl commented May 25, 2012

Fixed in r7991. Bernhard, if it's not too much to ask, it would be great if you could verify that this solves your issue.


Set owner to @kasperl.
Added Fixed label.

@DartBot
Copy link
Author

DartBot commented May 25, 2012

This comment was originally written by @bp74


Of course i'm happy to test it! I have good and bad news for you :)

The bug in this issue is fixed, now the "catch" block is called - which is good!

The bad thing is that a new issue came up:
SCRIPT5007: Unable to get value of the property 'charCodeAt$1': object is null or undefined

But i think we should open a new issue for this. The problem is that the "error" variable in the example above cannot be converted to a String. I have attached three new pictures with the call stack.


Attachments:
shot1.png (54.43 KB)
shot2.png (55.90 KB)
shot3.png (52.78 KB)

@DartBot
Copy link
Author

DartBot commented May 25, 2012

This comment was originally written by @bp74


Sorry, forgot to say i have tested with r7992.

@kasperl
Copy link

kasperl commented May 25, 2012

Thanks, Bernhard. Feel free to open a new issue. Looking forward to getting to the bottom of this!

copybara-service bot pushed a commit that referenced this issue Sep 27, 2022
…2 revisions)

https://dart.googlesource.com/dartdoc/+log/a6676ee58628..6b8b1c46da9a

2022-09-27 [email protected] Simplify _buildFullyQualifiedName (#3190)
2022-09-27 [email protected] Simplify Library.dirName (#3192)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/dart-doc-dart-sdk
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Dart Documentation Generator: https://github.com/dart-lang/dartdoc/issues
To file a bug in Dart SDK: https://github.com/dart-lang/sdk/issues

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md

Tbr: [email protected]
Change-Id: I5809e94dc7da449a2606414b24785d4ff8b70110
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261460
Reviewed-by: Nate Bosch <[email protected]>
Commit-Queue: Nate Bosch <[email protected]>
Commit-Queue: DEPS Autoroller <[email protected]>
This issue was closed.
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

4 participants