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

Incorrect propagation of RangeErrors in dart2js #12989

Closed
mkustermann opened this issue Sep 3, 2013 · 7 comments
Closed

Incorrect propagation of RangeErrors in dart2js #12989

mkustermann opened this issue Sep 3, 2013 · 7 comments
Assignees

Comments

@mkustermann
Copy link
Member

I'm currently preparing the next co19 roll to r569. Some co19 tests expect a RangeError to be thrown. But it seems like dart2js is converting RangeErrors coming from d8 to ArgumentErrors.

Here's an example tests/co19/src/LibTest/typed_data/ByteData/setInt8_A02_t01.dart:
main() {
  var byteData = new ByteData(0);
  try {
    byteData.setInt8(-1, 0);
    Expect.fail("RangeError is expected");
  } on RangeError catch(ok) {}
}

The generated code for main sees that the result of 'unwrapException' is not a RangeError so it will throw the raw exception (which is a V8 RangeError):

main: function() {
  var byteData, byteData0, exception, t1, t2;
  byteData0 = new DataView(new ArrayBuffer(0));
  byteData0.$dartCachedLength = byteData0.length;
  byteData = byteData0;
  try {
    $.setInt8$2$x(byteData, -1, 0);
    $.Expect__fail("Expect.fail('RangeError is expected')");
  } catch (exception) {
    t1 = $.unwrapException(exception);
    t2 = $.getInterceptor(t1);
    if (typeof t1 === "object" && t1 !== null && !!t2.$isRangeError)
      ;
    else
      throw exception;
  }

}},

$ ./tools/test.py -mrelease -cdart2js -rd8 co19/LibTest/typed_data/ByteData/setInt8_A02_t01

FAILED: dart2js-d8 release_ia32 co19/LibTest/typed_data/ByteData/setInt8_A02_t01
Expected: pass
Actual: fail
CommandOutput[dart2js]:
CommandOutput[d8]:

stdout:
out/ReleaseIA32/generated_tests/dart2js-d8/tests_co19_src_LibTest_typed_data_ByteData_setInt8_A02_t01/out.js:1220: RangeError: Offset is outside the bounds of the DataView
      throw exception;
            ^
RangeError: Offset is outside the bounds of the DataView
    at DataView.setInt8 (native)
    at ByteData.setInt8$2 (out/ReleaseIA32/generated_tests/dart2js-d8/tests_co19_src_LibTest_typed_data_ByteData_setInt8_A02_t01/out.js:1202:21)
    at $.setInt8$2$x (out/ReleaseIA32/generated_tests/dart2js-d8/tests_co19_src_LibTest_typed_data_ByteData_setInt8_A02_t01/out.js:1331:39)
    at main (out/ReleaseIA32/generated_tests/dart2js-d8/tests_co19_src_LibTest_typed_data_ByteData_setInt8_A02_t01/out.js:1212:7)
    at out/ReleaseIA32/generated_tests/dart2js-d8/tests_co19_src_LibTest_typed_data_ByteData_setInt8_A02_t01/out.js:1426:7
    at init.currentScript (out/ReleaseIA32/generated_tests/dart2js-d8/tests_co19_src_LibTest_typed_data_ByteData_setInt8_A02_t01/out.js:1396:5)
    at out/ReleaseIA32/generated_tests/dart2js-d8/tests_co19_src_LibTest_typed_data_ByteData_setInt8_A02_t01/out.js:1414:3
    at out/ReleaseIA32/generated_tests/dart2js-d8/tests_co19_src_LibTest_typed_data_ByteData_setInt8_A02_t01/out.js:1622:3

@kasperl
Copy link

kasperl commented Sep 18, 2013

Added this to the M7 milestone.

@kasperl
Copy link

kasperl commented Sep 23, 2013

Removed Priority-Unassigned label.
Added Priority-Medium label.

@kasperl
Copy link

kasperl commented Oct 2, 2013

Removed this from the M7 milestone.
Added this to the M8 milestone.

@kasperl
Copy link

kasperl commented Jun 4, 2014

Removed this from the M8 milestone.
Added this to the 1.6 milestone.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the 1.6 milestone.
Added Oldschool-Milestone-1.6 label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-1.6 label.

@rakudrama
Copy link
Member

It would be possible to translate JavaScript RangeErrors to Dart RangeErrors.
However, not all browsers throw JavaScript RangeErrors. Firefox appears to throw plain Error objects.

@kevmoo kevmoo removed the triaged label Mar 1, 2016
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