archives

« Bugzilla Issues Index

#2472 — 12.1.5.8 PropertyDefinitionEvaluation: Updating [[HomeObject]] for anonymous Function/GeneratorExpression inconsistent?


12.1.5.8 Runtime Semantics: PropertyDefinitionEvaluation
- PropertyDefinition : PropertyName : AssignmentExpression

Updating [[HomeObject]] for Function/GeneratorExpressions only if they're anonymous looks a bit strange. I wonder if [[HomeObject]] should be set here at all.

Test case for the current behaviour:
---
let obj = {
__proto__: {
a: () => "A",
b: () => "B",
},
a: function a() { return super() },
b: function() { return super() },
};

obj.a(); // throws a ReferenceError because [[HomeObject]] not set, cf. 8.1.2.4 NewFunctionEnvironment
obj.b(); // returns "B" because [[HomeObject]] was set in 12.1.5.8
---


I'm not sure why it is testing for anonymous, and it doesn't seem right to me.

The intend was to test for an actual literal function expression and only binding the home for those. the a and b property functions should both get bound in your eample. however, if there was an additional property
c: c //this doesn't get its home bound. It would require an explicit toMethod

where
let c= function() {return super()}



The above is basically what Rev23 does do I'm going to resolve this as fixed.

Reopen it if you this there is still an issue after you look at rev23.