rusty-ecma / RESSA

Rusty EcmaScript Syntax Analyzer
MIT License
111 stars 14 forks source link

Parse error: Redeclaration in Arrow function #66

Closed azw413 closed 2 years ago

azw413 commented 2 years ago

I've isolated this piece of code from a webpack which works on Node (and presumably in webkit) but results in the following error: Parse error in: simple/009-wp-arrow.js, LexicalRedecl(Position { line: 3, column: 14 }, Position { line: 4, column: 17 }, "one")

(() => {
    var deferred = [1, 2, 3, 4, 5];
    let arrow = (result, one, two, three) => {
            var [one, two, three] = deferred;
            result = one + two + three;
            return result;
        };
    console.log(arrow(5, 5, 5, 5));
    })();

Note that the parameter names one, two and three and being used destructure the array.

FreeMasen commented 2 years ago

woof, I'll try and take a stab at this one this weekend, might end up gutting (or making optional) the lexical re declaration checking as that should be opt-in for sure

azw413 commented 2 years ago

I kind of agree, this looks like it ought to be an error. I don't know why webpack is using code like this but apparently it does and it appears to be legal :(

FreeMasen commented 2 years ago

This should now be fix with version 0.7.6. Please let me know if you discover any regressions, I don't anticipate any but the solution was a little more broad than I was expecting and I want to be mindful of that.

azw413 commented 2 years ago

Thanks Robert !