Updates:
Status: Accepted
Owner: erights
Labels: -Type-Defect Type-DocDefect
Comment #1 on issue 1030 by erights: Assignment to a function declaration
identifier
http://code.google.com/p/google-caja/issues/detail?id=1030
Hi Kangax,
I'm relabeling this as a DocDefect, since the code is doing exactly what it
is
supposed to be doing here, but this "supposed to be" is not well
documented, as you
found out. Only Valija is attempting to be a reasonably complete emulation
of
ES5-strict, and I did verify that your example does what you expected in
Valija mode.
The rationale is that Cajita functions, in effect, are supposed to be
frozen.
However, for named functions, we do want to allow static members to be
initialized
before first use or escaping occurrence. In order to be able to impose a
mostly
static check on whether a use of a variable name should cause its value to
get
frozen, we need a reliable static distinction between variables holding
(potentially
not yet frozen) named functions vs all other variables.
For example,
function f(){ return 1; };
var g = f;
as Cajita cajoles to
var f;
//..
f = (function () {
function f$_self() { return 1; }
return ___.func(f$_self, 'f');
})();;;
var g = ___.primFreeze(f);
If f might have held some other value before escaping to g, then it would
have been
wrong to freeze it here.
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings