This name is both non-const-lexical-bound and var-bound
With the latest master, attempt to parse the following example:
function f(t, e) {
}
if (foo) // NO braces here.
function f(t, e) {
}
This fails with
This name is both non-const-lexical-bound and var-bound: IdentifierName(Dynamic("f"))', crates/binjs_es6/src/scopes.rs:251:13
Original file: https://player.ivideosmart.com/ivxplayer/v1/js/all.02201641.js
@arai-a you have touched this code more recently than me, do you want to take a look?
do you mean this is a regression?
No, I mean that you may understand that piece of code better than I do these days :)
If I'm wrong, don't worry, I'll take a look at it this week.
it's this case https://tc39.github.io/ecma262/#sec-functiondeclarations-in-ifstatement-statement-clauses and I think we don't handle Annex B things.
See, I knew you knew that stuff better than me :)
Maybe we should find a way to fail gracefully instead of asserting?
will try adding the handling, at least for strict mode.
to properly handle non-strict-mode code, we need to add block statement, or something like that (maybe, new interface for implicit block?), in order to store scope information for the function. that needs to be handled in the spec I think. I'll address strict mode case here.
we need to add block statement
Could you elaborate please? Where would it be inserted?
In non-strict code the second function is meant to shadow the first one if the condition is true, so they should share the same scope.
I misunderstood the current situation.
currently we're adding block with lexical scope for if (foo) { function f() {} }, but apparently that's wrong. (I was trying to align if (foo) function f() {} with that)
so, this should be fixed by changing the function declaration not-to-use lexical scope.