Closed
Bug 590672
Opened 14 years ago
Closed 14 years ago
treat ArrayBuffer() and SomeArrayType() as (0)
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: vlad, Assigned: vlad)
References
Details
(Whiteboard: fixed-in-tracemonkey)
Attachments
(1 file)
2.88 KB,
patch
|
shaver
:
review+
|
Details | Diff | Splinter Review |
We shouldn't be throwing on no args, should implicitly treat it as 0. This isn't super useful, but is more js-like.
Assignee | ||
Comment 1•14 years ago
|
||
Pretty simple patch. Just treats argc == 0 as if a 0 int was passed as the first arg.
Attachment #469201 -
Flags: review?(jorendorff)
Comment on attachment 469201 [details] [diff] [review] treat () as (0) Stealing.
Attachment #469201 -
Flags: review?(jorendorff) → review?(shaver)
Comment on attachment 469201 [details] [diff] [review] treat () as (0) ># HG changeset patch ># Parent b6b28598c817ad79848e69f1d967b8a6770b3512 >@@ -745,20 +742,17 @@ class TypedArrayTemplate > > ThisTypeArray *tarray = 0; > >- // must have at least one arg >- if (argc == 0) { >- JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, >- JSMSG_TYPED_ARRAY_BAD_ARGS); >- return false; >- } >+ // figure out the type of the first argument; >+ // no args is treated like an int arg of 0. >+ if (argc == 0 || argv[0].isInt32()) { >+ int32 len = 0; > >- // figure out the type of the first argument >- if (argv[0].isInt32()) { >- int32 len = argv[0].toInt32(); >+ if (argc > 0) >+ len = argv[0].toInt32(); >+ A little weird to have an == test and then a > test that follows for the same sort of distinction. Is there really much that's common in these blocks? r=shaver with clarifying reformat, or if you decide not to; I can go either way, though would prefer "!= 0" to "> 0" a fair bit.
Attachment #469201 -
Flags: review?(shaver) → review+
Assignee | ||
Comment 4•14 years ago
|
||
http://hg.mozilla.org/tracemonkey/rev/c497469955fa
Whiteboard: fixed-in-tracemonkey
Assignee | ||
Updated•14 years ago
|
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•