Issue metadata
Sign in to add a comment
|
ES6: 'this' is undefined if constructor has arrow function and calls super() |
||||||||||||||||||||
Issue description
Run this as a snippet or file and then inspect 'this' when it breakpoints, it will be undefined.
Sample code:
(function() {
class foo {
constructor() {
}
}
class bar extends foo {
constructor() {
super();
var b = () => this;
this.c = 'b'; // <-- Inspect 'this' (it will be undefined)
debugger;
}
}
new bar();
})();
,
Sep 26 2017
Sathya, please take a look!
,
Sep 26 2017
Thanks. Looping in marja as well.
,
Oct 3 2017
(also actually looping in marja@)
Commenting out the arrow function makes this work.
Scope with the arrow function --
Inner function scope:
function constructor () { // (0x5614a6efb578) (79, 219)
// strict mode scope
// 4 heap slots
// local vars:
CONST .this_function; // (0x5614a6efca50) never assigned
CONST this; // (0x5614a6efc9f0) forced context allocation, never assigned
CONST .new.target; // (0x5614a6efca20) never assigned
arrow () { // (0x5614a6efd0e8) (117, 127)
// strict mode scope
// 4 heap slots
}
}
Scope without the arrow function --
Inner function scope:
function constructor () { // (0x55b92fd48578) (79, 221)
// strict mode scope
// 4 heap slots
// local vars:
CONST this; // (0x55b92fd499f0) never assigned
CONST .this_function; // (0x55b92fd49a50) never assigned
CONST .new.target; // (0x55b92fd49a20) never assigned
}
This seems counter intuitive to me that the context allocated variable isn't available. The scopes seem correct to me. I'm curious if there's a bug in the way inspector reads the context variables especially the special synthetic ones like 'this' var.
+yang, can you take a look please?
,
Oct 4 2017
I will take a look as soon as I get back from Node Interactive (next week). Does this issue show through inspecting scopes (scopes panel) or via debug-evaluate (console)? There is some mismatch between the two. The scopes panel doesn't correctly show 'this' for arrow functions afair, which also should be fixed.
,
Oct 4 2017
Looks like this happen in both.
,
Oct 10 2017
The NextAction date has arrived: 2017-10-10
,
Jun 18 2018
Ping on this bug, as it is still active. |
|||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||
Comment 1 Deleted