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
Labels
Comments
Added this to the M7 milestone. |
Removed Priority-Unassigned label. |
Removed this from the 1.6 milestone. |
Removed Oldschool-Milestone-1.6 label. |
It would be possible to translate JavaScript RangeErrors to Dart RangeErrors. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The text was updated successfully, but these errors were encountered: