Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable not recognized inside if statement when declared as a block parameter #2

Closed
masak opened this issue Jan 3, 2015 · 1 comment

Comments

@masak
Copy link
Owner

masak commented Jan 3, 2015

$ perl6 bin/007 -e="if [1, 2, 3] -> a { say(a) }"
Variable 'a' is not declared
  in method find at /home/masak/mine/007/lib/_007/Runtime.pm:74
  in method get-var at /home/masak/mine/007/lib/_007/Runtime.pm:83
  in method eval at /home/masak/mine/007/lib/_007/Q.pm:69
  in method dispatch:<hyper> at src/gen/m-CORE.setting:1351
  in method eval at /home/masak/mine/007/lib/_007/Q.pm:196
  in method run at /home/masak/mine/007/lib/_007/Q.pm:243
  in method run at /home/masak/mine/007/lib/_007/Q.pm:438
  in method run at /home/masak/mine/007/lib/_007/Q.pm:261
  in method run at /home/masak/mine/007/lib/_007/Q.pm:438
  in method run at /home/masak/mine/007/lib/_007/Runtime.pm:28
  in sub run_007 at bin/007:8
  in sub MAIN at bin/007:15
  in sub MAIN at bin/007:11
  in block <unit> at bin/007:15

Closable with a fix and a regression test.

@masak
Copy link
Owner Author

masak commented Jan 3, 2015

I was sure we had a test for this. And we do, in corner-cases.t.

{
    my $program = q:to/./;
        if "James" -> s {
            say(s);
        }
        .

    my $ast = q:to/./;
        (statements
          (if (str "James") (block (parameters (ident "s")) (statements
            (stexpr (call (ident "say") (arguments (ident "s"))))))))
        .

    parses-to $program, $ast, "if statement with a pointy block";
}

But the test only makes sure we compile to the right AST. Something must be going wrong after that. Perhaps in the way Q::Statement::If handles its parameter declaration?

@masak masak closed this as completed in cda9318 Jan 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant