Open szegedi opened 1 year ago
Am working on #939 and attempting to make the const impl. use the existing let implementation as in EcmaScript they are exactly the same scope-wise, and the only main difference being consts having to get initialized on declaration and being readOnly from that point forward
In the process I might already fix this issue as well, although so far I've just been fixing it in interpreted mode, while I think you're trying it compiled?
Hi Paul, good to hear you're working on this!
I tried it both in interpreted and compiled. I think the AST transformations in question take place in the common path for both interpreted and compiled code generation. This came to my attention through some folks that use Rhino for their commercial product, and they're using it in interpreted mode 'cause they use continuations, so if you first fix it in interpreted, that's great!
prints
undefined
then1
. Same code in V8 printsundefined
twice as expected. For a quick shell repro:Investigating the issue, the JS bytecode created is:
We see there's a
ONE; SETVAR1 1
to set the value to 1 after the console.log call, but the originallet x;
resulted in no code.The problem most likely lies in
NodeTransformer
that'll entirely transform away an initializer-less(LET (NAME x))
AST node instead of initializing the variable to undefined.