mirror of
https://github.com/RGBCube/serenity
synced 2025-06-28 21:02:07 +00:00
LibJS: Bring Reference records a bit closer to the ECMAScript spec
Our Reference class now has the same fields as the spec: - Base (a non-nullish value, an environment record, or `unresolvable`) - Referenced Name (the name of the binding) - Strict (whether the reference originated in strict mode code) - ThisValue (if non-empty, the reference represents a `super` keyword) The main difference from before is that we now resolve the environment record that a reference interacts with. Previously we simply resolved to either "local variable" or "global variable". The associated abstract operations are still largely non-conforming, since we don't yet implement proper variable bindings. But this patch should at least fix a handful of test262 cases. :^) There's one minor regression: some TypeError message strings get a little worse due to doing a RequireObjectCoercible earlier in the evaluation of MemberExpression.
This commit is contained in:
parent
6e1932e8b2
commit
bce7fdba81
6 changed files with 193 additions and 123 deletions
|
@ -18,12 +18,9 @@ test("basic functionality", () => {
|
|||
[null, undefined].forEach(primitive => {
|
||||
expect(() => {
|
||||
primitive.foo = "bar";
|
||||
}).toThrowWithMessage(TypeError, `Cannot set property 'foo' of ${primitive}`);
|
||||
}).toThrowWithMessage(TypeError, `${primitive} cannot be converted to an object`);
|
||||
expect(() => {
|
||||
primitive[Symbol.hasInstance] = 123;
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
`Cannot set property 'Symbol(Symbol.hasInstance)' of ${primitive}`
|
||||
);
|
||||
}).toThrowWithMessage(TypeError, `${primitive} cannot be converted to an object`);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue