2.1.11 [ECMA-262/7] Section 12.15.4 Runtime Semantics: Evaluation
V0194: After an assignment, the name of the function is the empty string
The specification states:
-
12.15.4 Runtime Semantics: Evaluation AssignmentExpression : LeftHandSideExpression = AssignmentExpression 1. If LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral, then a. Let lref be the result of evaluating LeftHandSideExpression. b. ReturnIfAbrupt(lref). c. Let rref be the result of evaluating AssignmentExpression. d. Let rval be ? GetValue(rref). e. If IsAnonymousFunctionDefinition(AssignmentExpression) and IsIdentifierRef of LeftHandSideExpression are both true, then i. Let hasNameProperty be ? HasOwnProperty(rval, "name"). ii. If hasNameProperty is false, perform SetFunctionName(rval, GetReferencedName(lref)).
EdgeHTML Mode
After the following assignment:
var f = function () {}
the name of the function held in f is the empty string.
V0195: The reference is retrieved twice
The specification states:
-
12.15.4 Runtime Semantics: Evaluation AssignmentExpression : LeftHandSideExpression = AssignmentExpression 1. If LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral, then a. Let lref be the result of evaluating LeftHandSideExpression. b. ReturnIfAbrupt(lref). c. Let rref be the result of evaluating AssignmentExpression. d. Let rval be ? GetValue(rref). e. If IsAnonymousFunctionDefinition(AssignmentExpression) and IsIdentifierRef of LeftHandSideExpression are both true, then i. Let hasNameProperty be ? HasOwnProperty(rval, "name"). ii. If hasNameProperty is false, perform SetFunctionName(rval, GetReferencedName(lref)). f. Perform ? PutValue(lref, rval). g. Return rval. ... AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression 1. Let lref be the result of evaluating LeftHandSideExpression. 2. Let lval be ? GetValue(lref). 3. Let rref be the result of evaluating AssignmentExpression. 4. Let rval be ? GetValue(rref). 5. Let op be the @ where AssignmentOperator is @= 6. Let r be the result of applying op to lval and rval as if evaluating the expression lval op rval. 7. Perform ? PutValue(lref, r). 8. Return r.
EdgeHTML Mode
In the algorithm for
AssignmentExpression : LeftHandSideExpression = AssignmentExpression
the following steps are added before step 1f:
i. Type(lref) is Reference and if IsUnresolvableReference(_lref_) is false and IsPropertyReference(_lref_) is false then
1. Assert: lref is a reference to an Environment Record.
2. Let lref be the result of evaluating an Identifier _id_ whose StringValue is GetReferencedName(lref) as if _id_ were a LeftHandSidelrefession.
3. ReturnIfAbrupt(lref);
As a result, the reference is retrieved twice.
In the algorithm for
Assignmentlrefession : LeftHandSidelrefession AssignmentOperator Assignmentlrefession
the following steps are added between steps 4 and 5:
a. Type(lref) is Reference and if IsUnresolvableReference(_lref_) is false and IsPropertyReference(_lref_) is false then
i. Assert: lref is a reference to an Environment Record.
ii. Let lref be the result of evaluating an Identifier _id_ whose StringValue is GetReferencedName(lref) as if _id_ were a LeftHandSidelrefession.
iii. ReturnIfAbrupt(lref);
As a result, the reference is retrieved twice.