W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2012

[Bug 15986] New: Specify exactly how and when ECMAScript arguments are evaluated

From: <bugzilla@jessica.w3.org>
Date: Tue, 14 Feb 2012 16:52:20 +0000
To: public-script-coord@w3.org
Message-ID: <bug-15986-3890@http.www.w3.org/Bugs/Public/>

           Summary: Specify exactly how and when ECMAScript arguments are
           Product: WebAppsWG
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: WebIDL
        AssignedTo: cam@mcc.id.au
        ReportedBy: ayg@aryeh.name
         QAContact: member-webapi-cvs@w3.org
                CC: bzbarsky@mit.edu, mike@w3.org,

Consider the following:

data:text/html,<!doctype html>
var x = 'unchanged';
try {
{ valueOf: function() {x = 'changed'; return 0;} } );
} catch (e) {}
document.documentElement.textContent = x;

It outputs "unchanged" in Firefox 13.0a1, and "changed" in IE10 Developer
Preview, Chrome 18 dev, and Opera Next 12.00 alpha.  This outputs "changed" in
all four browsers:

data:text/html,<!doctype html>
var x = 'unchanged';
try {
{ valueOf: function() {x = 'changed'; return 0;} },
} catch (e) {}
document.documentElement.textContent = x;

So it seems like Gecko evaluates the arguments one by one, and throws when it
hits the first bad argument.  Other browsers seem to evaluate all at once. 
Which is correct?

Also, with things like this that have side effects, it's important that the
number of evaluations is defined.  Given this:

data:text/html,<!doctype html>
var cnt = 0;
{ valueOf: function() {cnt++; return 1;} });
document.documentElement.textContent = cnt;

Chrome outputs "2", and the other three output "1".  Presumably we want "1".

The spec should say exactly how all this works.  I'm not sure what the right
answer is, actually.  We need to evaluate the arguments before we can run the
overload resolution algorithm, but to evaluate the arguments we want to know
what types we're trying to evaluate them as, right?

Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
Received on Tuesday, 14 February 2012 16:52:26 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:05 UTC