Issue 838 in v8: Function [[Call]] should return Reference Type

20 views
Skip to first unread message

codesite...@google.com

unread,
Aug 22, 2010, 4:20:17 PM8/22/10
to v8-...@googlegroups.com
Status: New
Owner: ----

New issue 838 by utatane....@gmail.com: Function [[Call]] should return
Reference Type
http://code.google.com/p/v8/issues/detail?id=838

v8 set Left Hand Side Error in parsing phase and reduces Identifier +
PropertyAccess as ValidLeftHandSide, but, Function [[Call]] returns
Reference Type.

in following case,

console.log("TEST") = "VAL";

before v8 raises ReferenceError: "Invalid left-hand side in assignment",
console.log("TEST") should be called.


codesite...@google.com

unread,
Oct 3, 2011, 3:17:23 AM10/3/11
to v8-...@googlegroups.com
Updates:
Status: Accepted
Labels: ES5

Comment #1 on issue 838 by l...@chromium.org: Function [[Call]] should

This is correct. While V8 never has a function return a Reference, it would
be against the spirit of ES5 section 16 to consider this an early error
(unlike, e.g., the assignment "3=4").

The spec isn't entirely clear, due to the wording of the last case where
Early Errors are required: "Attempts to call PutValue on any value for
which an early determination can be made that the value is not a Reference
(for example, executing the assignment statement 3=4)."
V8 can actually determine early that a function call isn't a Reference,
because it never is in V8, but that seems counter to the intended meaning
when reading the following sentence: "An implementation shall not treat
other kinds of errors as early errors even if the compiler can prove that a
construct cannot execute without error under any circumstances.".


codesite...@google.com

unread,
Oct 30, 2012, 12:41:16 PM10/30/12
to v8-...@googlegroups.com

Comment #2 on issue 838 by swivelgames: Function [[Call]] should return
Reference Type
http://code.google.com/p/v8/issues/detail?id=838

But is it safe to say that, theoretically, a function *could* return a
reference? Like, in the example below...

var myObj = new Object();
function myFunc() {
myObj.test = "blah";
return myObj;
}
myFunc() = new String("foobar");

Shouldn't `myObj` now become a primitive string called "foobar"? Afterall,
the engine treats variables in JavaScript more like reference holders than
actual variables. This seems like it would be proper JavaScript....
Especially since the following is valid...

myFunc().test = "rawr";
console.log(myObj.test); // Prints out "rawr"

This early error is actually in violation of both Early Errors but also
Section 8.7, "The Reference Specification Type"
(http://es5.github.com/#x8.7)

Technically the first example I gave is completely legal, although it is
only a side-affect of the intended capabilities. Still, it is clearly
written that it is indeed a side-affect but does indeed need to function
that way. Just as chainability has spawned from this very ability, the
first example is clearly legal. It is only limited due to the Early Error.
Otherwise, technically, the first example should work.

codesite...@google.com

unread,
Oct 30, 2012, 12:42:16 PM10/30/12
to v8-...@googlegroups.com

Comment #3 on issue 838 by swivelgames: Function [[Call]] should return
Reference Type
http://code.google.com/p/v8/issues/detail?id=838

But is it safe to say that, theoretically, a function *could* return a
reference? Like, in the example below...

var myObj = new Object();
function myFunc() {
myObj.test = "blah";
return myObj;
}
myFunc() = new String("foobar");

Shouldn't `myObj` now become a primitive string with a value of "foobar"?
After all, the engine treats variables in JavaScript more like reference

codesite...@google.com

unread,
Oct 30, 2012, 12:43:16 PM10/30/12
to v8-...@googlegroups.com

Comment #4 on issue 838 by swivelgames: Function [[Call]] should return
Reference Type
http://code.google.com/p/v8/issues/detail?id=838

But is it safe to say that, theoretically, a function *could* return a
reference? Like, in the example below...

var myObj = new Object();
function myFunc() {
myObj.test = "blah";
return myObj;
}
myFunc() = new String("foobar");

Shouldn't `myObj` now become a primitive string called "foobar"? Afterall,
the engine treats variables in JavaScript more like reference holders than
actual variables. This seems like it would be proper JavaScript....
Especially since the following is valid...

myFunc().test = "rawr";
console.log(myObj.test); // Prints out "rawr"

This early error is actually in violation of both Early Errors but also
Section 8.7, "The Reference Specification Type"
(http://es5.github.com/#x8.7)

Technically the first example I gave is completely legal, although it is
only a side-affect of the intended capabilities. Still, it is clearly
written that it is indeed a side-affect but does indeed need to function
that way. Just as chainability has spawned from this very ability, the
first example is clearly legal. It is only limited due to the Early Error
implemented in the engine. Otherwise, technically, the first example should
work.

codesite...@google.com

unread,
Feb 19, 2015, 5:27:34 PM2/19/15
to v8-...@googlegroups.com

Comment #5 on issue 838 by ruihfaze...@gmail.com: Function [[Call]] should
return Reference Type
https://code.google.com/p/v8/issues/detail?id=838

will that be changed? it would be a great benefit...

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

codesite...@google.com

unread,
Feb 19, 2015, 6:05:43 PM2/19/15
to v8-...@googlegroups.com
Updates:
Cc: ma...@chromium.org a...@chromium.org dsl...@chromium.org

Comment #6 on issue 838 by a...@chromium.org: Function [[Call]] should
ES6 makes this a a SyntaxError I believe.

Having a function return a reference was something the DOM used to need but
it was never exposed to user script. The DOM removed all of these cases and
the ES spec might disallow it now.

codesite...@google.com

unread,
Aug 14, 2015, 12:38:17 PM8/14/15
to v8-...@googlegroups.com
Updates:
Status: WontFix
Owner: ad...@chromium.org
Cc: rossb...@chromium.org

Comment #8 on issue 838 by ad...@chromium.org: Function [[Call]] should
return Reference Type
https://code.google.com/p/v8/issues/detail?id=838

We won't ever make calls assignable, but we might consider trying to make
such expressions early errors in future (as arv suggested in #6). But
that'd be a separate issue.
Reply all
Reply to author
Forward
0 new messages