FWIW I think that's expected. Strict mode would throw otherwise but of course if you have an outer scope reference to whatever you are invoking that's indeed what you invoke.
Making it behave similarly in both strict and non strict would be a mistake for the existing sloppy code but I agree that in strict mode that should probably warn (at least) regardless. On Tue, Jan 19, 2016 at 5:54 PM, Kevin Gibbons <[email protected]> wrote: > I'm not sure if this is well-known; it was certainly surprising to me. > > Consider the following program: > `let func = () => 0; > > (function(){ > { > function func() { > return 1; > } > } > return func(); > })();` > > The return value of the second function depends on whether this program is > evaluated in strict mode or not. In strict mode (for example, as a Module), > annex B.3.3 does not apply, so it returns 0. In sloppy mode (for example, > as a Script), annex B.3.3 applies and it returns 1. > > You can see how the semantics change on the scope analysis demo we've just > put up at > shift-ast.org/scope.html?code=let%20func%20%3D%20()%20%3D%3E%200%3B%0A%0A(function()%7B%0A%20%20%7B%0A%20%20%20%20function%20func()%20%7B%0A%20%20%20%20%20%20return%201%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20return%20func()%3B%0A%7D)()%3B#demo > : as a Module the last `func` identifier refers to the outer `func`, and as > a Script it refers to the inner one. > > Is it considered acceptable to have such large changes in strict vs > non-strict semantics for unremarkable code? If not, should B.3.3 be made to > apply in strict mode? > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

