-
-
Save masak/56e03f67ab6f030791e7 to your computer and use it in GitHub Desktop.
Debug statements near a bug I'm investigating
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
{ | |
my $ast = q:to/./; | |
(statements | |
(sub (ident "f") (parameters) (statements | |
(my (ident "b") (assign (ident "b") (block (parameters) (statements | |
(return (int 5)))))) | |
(sub (ident "g") (parameters) (statements | |
(stexpr (call (ident "b") (arguments))))) | |
(stexpr (call (ident "g") (arguments))) | |
(stexpr (call (ident "say") (arguments (str "Dead code. Should have returned from f.")))))) | |
(stexpr (call (ident "f") (arguments)))) | |
. | |
is-result $ast, "", "return statements bind lexically to their surrounding subroutine"; | |
} |
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
RUNTIME RUN | |
INVOKING Q::Identifier.new(name => "f") | |
GET-VAR f | |
FIND LOOKING IN Frame|197586992 (elems, charat, int, lc, trim, sorted, prefix:<->, min, join, index, grep, map, f, abs, chr, ord, uc, reversed, substr, type, max, chars, Q::Literal::Str, Q::Arguments, str, split, Q::Identifier, say, Q::Postfix::Call, infix:<+>) | |
THE THING WE GOT WAS A Val::Sub | |
DECLARE-VAR g | |
PUT-VAR g | |
FIND LOOKING IN Frame|197587088 (g) | |
THE THING WE PUT WAS A Val::Sub | |
DECLARE-VAR b | |
PUT-VAR b | |
FIND LOOKING IN Frame|197587088 (g, b) | |
THE THING WE PUT WAS A Val::None | |
DECLARE-VAR --RETURN-TO-- | |
PUT-VAR --RETURN-TO-- | |
FIND LOOKING IN Frame|197587088 (g, b, --RETURN-TO--) | |
THE THING WE PUT WAS A Frame | |
ASSIGNING b | |
(value): Val::Block | |
PUT-VAR b | |
FIND LOOKING IN Frame|197587088 (g, b, --RETURN-TO--) | |
THE THING WE PUT WAS A Val::Block | |
GET-VAR b | |
FIND LOOKING IN Frame|197587088 (g, b, --RETURN-TO--) | |
THE THING WE GOT WAS A Val::Block <--- look, so we even see that we stored it correctly | |
HM: Val::Block | |
INVOKING Q::Identifier.new(name => "g") | |
GET-VAR g | |
FIND LOOKING IN Frame|197587088 (g, b, --RETURN-TO--) | |
THE THING WE GOT WAS A Val::Sub | |
DECLARE-VAR --RETURN-TO-- | |
PUT-VAR --RETURN-TO-- | |
FIND LOOKING IN Frame|197587136 (--RETURN-TO--) | |
THE THING WE PUT WAS A Frame | |
INVOKING Q::Identifier.new(name => "b") | |
GET-VAR b | |
FIND LOOKING IN Frame|197587136 (--RETURN-TO--) | |
FIND LOOKING IN Frame|197586944 (g, b) | |
THE THING WE GOT WAS A Val::None <--- and now when we look again from inside sub g, the block is gone | |
Trying to invoke a None | |
in method eval at /home/masak/ours/007/lib/_007/Q.pm:228 | |
in method run at /home/masak/ours/007/lib/_007/Q.pm:275 | |
in method run at /home/masak/ours/007/lib/_007/Q.pm:451 | |
in method call at /home/masak/ours/007/lib/_007/Runtime.pm:184 | |
in method eval at /home/masak/ours/007/lib/_007/Q.pm:231 | |
in method run at /home/masak/ours/007/lib/_007/Q.pm:275 | |
in method run at /home/masak/ours/007/lib/_007/Q.pm:451 | |
in method call at /home/masak/ours/007/lib/_007/Runtime.pm:184 | |
in method eval at /home/masak/ours/007/lib/_007/Q.pm:231 | |
in method run at /home/masak/ours/007/lib/_007/Q.pm:275 | |
in method run at /home/masak/ours/007/lib/_007/Q.pm:451 | |
in method run at /home/masak/ours/007/lib/_007/Runtime.pm:31 | |
in sub is-result at /home/masak/ours/007/lib/_007/Test.pm:186 | |
in block <unit> at t/semantics/return.t:18 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, spotted it.
Lines 25 and 38 should be the same frame/pad, but they're different. Likely one of them is the static frame/pad.