Closed
Bug 521772
Opened 15 years ago
Closed 6 years ago
Clean up the API for toFixed, toPrecision, and toExponential
Categories
(Tamarin Graveyard :: Virtual Machine, defect, P3)
Tamarin Graveyard
Virtual Machine
Tracking
(Not tracked)
RESOLVED
WONTFIX
Q1 12 - Brannan
People
(Reporter: lhansen, Unassigned)
References
Details
Attachments
(1 file)
378.52 KB,
patch
|
stejohns
:
review-
|
Details | Diff | Splinter Review |
The current implementation is not according to ECMA-262: the default argument values are 0, but in some cases need to be undefined because those two values are distinguished (undefined means "as many digits as necessary" and 0 means "zero"). The distinction is lost and must be recovered, and then passed on to the underlying machinery.
Also, at the highest level these methods are incorrectly implemented. Both toExponential and toPrecision will return NaN/Infinity values regardless of the parameter value, ie, the error check currently happens too soon.
Reporter | ||
Comment 1•15 years ago
|
||
Patch is big because it contains a change to builtin.cpp.
Several levels of fix here:
- Number.as is changed to distinguish between 'undefined'/'not supplied' and
'0' arguments, as required by E262-3
- NumberClass.cpp is changed to make use of that distinction, and to signal
errors for toPrecision/toExponential later, in accordance with E262-3
- MathUtils.cpp is changed to make use of the undefined/0 distinction; as a
side effect we fix bug #478804.
One reason for disliking this patch might be that it fails to correctly report
the value of an illegal precision/fractionDigits parameter when it throws an
error, because the precision argument to Number::convert is changed by the AS3
code. If this is seen as an important problem then it can be fixed, either by
passing that value as an atom or by adding a parameter.
Attachment #405837 -
Flags: review?(stejohns)
Updated•15 years ago
|
Attachment #405837 -
Flags: review?(stejohns) → review-
Comment 2•15 years ago
|
||
Comment on attachment 405837 [details] [diff] [review]
Patch
I actually like the patch, but I am rejecting only because I think we have to figure out whether or not this needs to be version-checked for Flash compatibility (and if so the patch will need some reworking).
Reporter | ||
Updated•15 years ago
|
Whiteboard: Has patch
Reporter | ||
Updated•15 years ago
|
Priority: P2 → P3
Comment 3•15 years ago
|
||
Any fix for this bug will likely need version-checking for backwards compatibility.
Updated•15 years ago
|
Flags: in-testsuite?
Reporter | ||
Updated•15 years ago
|
Whiteboard: Has patch → Has patch; versioning
Reporter | ||
Updated•15 years ago
|
Whiteboard: Has patch; versioning → Has patch
Updated•15 years ago
|
Target Milestone: flash10.1 → Future
Reporter | ||
Updated•15 years ago
|
Assignee: lhansen → nobody
Priority: P3 → --
Comment 4•15 years ago
|
||
This is a mass change. Every comment has "assigned-to-new" in it.
I didn't look through the bugs, so I'm sorry if I change a bug which shouldn't be changed. But I guess these bugs are just bugs that were once assigned and people forgot to change the Status back when unassigning.
Status: ASSIGNED → NEW
Updated•14 years ago
|
Assignee: nobody → stejohns
Flags: flashplayer-qrb+
Comment 5•14 years ago
|
||
I grabbed this bug and looked at applying BugCompatibility to it, but unfortunately it's tricky: there's no way to use BugCompatibility to change the value of default arguments, and we can't distinguish a filled-in vs explicitly-specified value of void(0) as the argument... it would be painful to add customization of default args to the BugCompatibility framework, so, looking for another approach, two things come to mind, neither of which are particularly appealing...
AS3 function toPrecision(...):String
{
if (arguments.length > 1) throw(kWrongArgCountError);
var p;
if (arguments.length == 0)
p = bugzilla(521772) ? void(0) : 0;
else
p = arguments[0];
// rest of logic
}
AS3 function toPrecision(p="constantStringWeAssumeWillNeverBePassed"):String
{
if (p === "constantStringWeAssumeWillNeverBePassed")
p = bugzilla(521772) ? void(0) : 0;
// rest of logic
}
thoughts?
Reporter | ||
Comment 6•14 years ago
|
||
Actually the first of your solutions is fine, if it's cleaned up a little (you can't use both ... and 'arguments', and you don't want to use 'arguments' in any case), because the rest arguments optimization will prevent any storage allocation from occurring:
AS3 function toPrecision(...rest): String {
if (rest.length > 1) throw(...);
var p;
if (rest.length == 0)
p = ...;
else
p = rest[0];
...;
}
Comment 7•14 years ago
|
||
updating milestone to Serrano as the two dependent issues were targeted to Serrano.
Flags: flashplayer-bug+
Whiteboard: Has patch → Has-patch must–fix-candidate
Target Milestone: Future → flash10.x-Serrano
Updated•14 years ago
|
Whiteboard: Has-patch must–fix-candidate → Has-patch, must-fix-candidate
Flags: flashplayer-injection-
Priority: -- → P3
Target Milestone: Q3 11 - Serrano → Q1 12 - Brannan
Assignee: stejohns → lhansen
Whiteboard: Has-patch, must-fix-candidate → Has-patch
Reporter | ||
Updated•13 years ago
|
Status: NEW → ASSIGNED
Whiteboard: Has-patch
Reporter | ||
Updated•13 years ago
|
Assignee: lhansen → nobody
Status: ASSIGNED → NEW
Comment 8•6 years ago
|
||
Tamarin isn't maintained anymore. WONTFIX remaining bugs.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•