When trying to encode the string "undefined", it encodes it as [[][[]]]+[]
However, this is wrong, because [[][[]]] evaluates to [undefined] and when converting this to string by +[], then it results in ""
I think it should either get the first element by [+[]] and then converting to string, so the result should be: [[][[]]][+[]]+[], or better yet, not wrap undefined into an array, by getting it to [][[]]+[]
This is in a fact an issue. I believe the only way to solve this problem is to become context-aware. Perhaps we could rewrite and piggy back on Acorn or Espree?
This would be massively slower, but it is the right way to do it. We should generate bytecode from the AST.
When trying to encode the string "undefined", it encodes it as
[[][[]]]+[]
However, this is wrong, because
[[][[]]]
evaluates to[undefined]
and when converting this to string by+[]
, then it results in""
I think it should either get the first element by
[+[]]
and then converting to string, so the result should be:[[][[]]][+[]]+[]
, or better yet, not wrap undefined into an array, by getting it to[][[]]+[]