22:01
<Duncan MacGregor>

While trying to get some corner cases correct around scoping and shadowing I noticed that engine 262 disagrees with v8 and jsc when evaluating the following

function h() {
    function f() { return 1; }
    var r = "";
    r += f();
    for (var i = 0; i < 10; i++) {
        r += f();
        function f() { return 0;}
    }
    r += f();
    return r;
}
h();
22:03
<Duncan MacGregor>
Engine 262 is giving '100000000001', while v8 and jsc are giving '100000000000'.
22:05
<mgaudet>
(Firefox matches v8 and jsc)
22:05
<Duncan MacGregor>
Normally I'd trust engine 262 to be correct, but I'm struggling to see why in this case.
22:18
<ljharb>
is that some sloppy mode annex b function scoping nonsense perhaps?
22:18
<ljharb>
like, put it all in strict mode, what do they all say?
22:23
<Duncan MacGregor>
Yeah, looks like it, in strict mode they all agree.
22:24
<Duncan MacGregor>
Guess I need to go through annex b and work out which bit is governing this, and order a shirt that says, "It's always fucking Annex B." :-)
22:28
<ljharb>
(engine262 likely never chose to implement that sloppy function annex b stuff)
22:35
<Duncan MacGregor>
I think I've found where this is all specified, and I guess I'll have to preserve our engine's current behaviour in non-strict mode.
22:35
<Richard Gibson>
it smells like https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics . Declaring functions in blocks is super chaotic.
22:36
<Duncan MacGregor>
Yeah, it is exactly that.