-
-
Save caitp/889d1c39728d4556f43b to your computer and use it in GitHub Desktop.
CL#1104223002 difficulties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
// Totally fine, no problem resolving function declarations: | |
"use strict"; | |
function A() { return "hi!"; } | |
function B() { return C(A); } | |
function C(F) { return F(); } | |
return B(); | |
})() // "hi!" | |
(function() { | |
"use strict"; | |
// Totally fine, even with the default param in A, no FunctionDeclaration needs to be resolved, works great | |
function A(s = "HI") { return s; } | |
function B() { return C(A); } | |
function C(F) { return F(); } | |
return B(); | |
})() // "HI" | |
(function(x = 1) { | |
"use strict"; | |
function A() { return "HI"; } | |
function B() { return C(A); } | |
function C(F) { return F(); } | |
// Problem: `B` resolves to undefined. It's a maze trying to figure out why, | |
// because non-function declarations resolve just fine | |
return B(); | |
})() // TypeError: B is not a function |
with the adjustment above, there's a new problem :(
(function(x = 1) {
"use strict";
function A() { return "HI"; }
// Problem: `C` apparently doesn't resolve. It's a maze trying to figure out why,
// because non-function declarations resolve just fine, and calling `B` worked
// just fine too. -_____-------- Walking through in the debugger, it looks like it does
// actually resolve :|
function B() { return C(A); }
function C(F) { return F(); }
return B();
})() // ReferenceError: C is not defined
;____; --- there's got to be a better way
The DeclareDynamicGlobal() path gets taken sometimes, and C
isn't declared in the global scope normally, so... :((
Bug occurs when Compiler::GetLazyCode()
is used, it makes sense because the scope hierarchy is totally messed up (which would be why it gets this wrong). I'm not sure why this worked before
# --no-lazy
(lldb) r --test --random-seed=1337758917 --nocrankshaft --nohard-abort --nodead-code-elimination --nofold-constants --enable-slow-asserts --debug-code --verify-heap /Users/caitp/v8/test/mjsunit/mjsunit.js /Users/caitp/v8/test/mjsunit/harmony/optional-arguments.js --no-lazy
Process 73551 launched: '/Users/caitp/v8/out/x64.debug/d8' (x86_64)
Process 73551 exited with status = 0 (0x00000000)
# not --no-lazy
(lldb) r --test --random-seed=1337758917 --nocrankshaft --nohard-abort --nodead-code-elimination --nofold-constants --enable-slow-asserts --debug-code --verify-heap /Users/caitp/v8/test/mjsunit/mjsunit.js /Users/caitp/v8/test/mjsunit/harmony/optional-arguments.js
Process 73517 launched: '/Users/caitp/v8/out/x64.debug/d8' (x86_64)
/Users/caitp/v8/test/mjsunit/mjsunit.js:178: Failure: expected <Object <Error()> is not an instance of <ReferenceError> but of < SyntaxError>> found <undefined>
throw new MjsUnitAssertionError(message);
^
Error
at new MjsUnitAssertionError (/Users/caitp/v8/test/mjsunit/mjsunit.js:31:16)
at fail (/Users/caitp/v8/test/mjsunit/mjsunit.js:178:11)
at assertInstanceof (/Users/caitp/v8/test/mjsunit/mjsunit.js:345:7)
at assertThrows (/Users/caitp/v8/test/mjsunit/mjsunit.js:326:9)
at /Users/caitp/v8/test/mjsunit/harmony/optional-arguments.js:58:4
Process 73517 exited with status = 1 (0x00000001)
(lldb)
I'm gonna cry /).(\
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mystery solved, my Scope::AddDeclaration() hack doesn't deal with this in strict mode, because the declaration type is
LET
there.