mirror of https://github.com/boa-dev/boa.git
Browse Source
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel neccesary.
--->
This Pull Request fixes: 79e3bc5176/test/language/computed-property-names/object/method/super.js
This PR solves the bug of using the `super` keyword in the method attribute of object. When the environment is `None`, the `vm` gets the top element of `vm.stack` as `this`, such as:
```js
var a = {
f() {
return super.m();
}
};
var b = {
m() {
retrun "super";
}
};
Object.setPrototypeOf(a, b);
a.f(); // the top of stack is `a`
let f = a.f;
f(); // the top of stack is `global_this`, so `super` cannot be used
```
### Can be improved
What I think is that when I use `object.method()`, the engine should bind `this_object` to the `environment`, instead of using `vm.stack.last()...`.
### TODOS
1. `super` need to look for properties all the way to the end.
Co-authored-by: creampnx_x <2270436024@qq.com>
pull/2278/head
creampnx_x
2 years ago
2 changed files with 56 additions and 1 deletions
Loading…
Reference in new issue