Closed twolfson closed 10 years ago
Boiled this down and found the cause of the issue but I don't actually know what the expected behavior should be =(
https://github.com/twolfson/rocambole/compare/bug;cannot.parse.comma.arrays
The root of the problem is esprima
returns the following AST for our regression:
// Part of `esprima.parse('a = [,]`);`
{ type: 'ArrayExpression', elements: [ null ], range: [ 4, 7 ] }
The specific part that is in reference to is our array [,]
. When we walk over this array, the element is null
. As a result, when instrumentNodes
attempts to set a value on null
, it errors out.
https://github.com/millermedeiros/rocambole/blob/v0.3.2/rocambole.js#L371-L373
However, the rub is I am not sure what the expected behavior for that is. Do we skip it? Do we upcast it to the equivalent of a = [undefined]
?
This issue has been stale for a month and the problem persists. Can we decide what action to take?
I use this enough in my tests that this makes esformatter-diff crash :frowning:
I'm also not sure on what to do.. but I guess the best thing is to keep the AST as is, and just skip the null
during the instrumentation for now.
sorry for not replying to this before, was swamped with other tasks and totally forgot about it.
this is still failing on the moonwalk
call since null
doesn't have a depth..
esformatter v0.3.2 should fix this issue \o/
Thanks @millermedeiros ! =D
I ran into a snag while trying out
esformatter
, it cannot format:The stack trace in both cases:
For reference, I was beautifying minified source code which is probably how that got introduced.
http://www.kimonolabs.com/js/kimono.min.js