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

Colonpairs with indirect-lookup as variables fail to compile right #1532

Open
zoffixznet opened this issue Feb 16, 2018 · 3 comments
Open

Colonpairs with indirect-lookup as variables fail to compile right #1532

zoffixznet opened this issue Feb 16, 2018 · 3 comments

Comments

@zoffixznet
Copy link
Contributor

@zoffixznet zoffixznet commented Feb 16, 2018

Spotted here: https://stackoverflow.com/questions/44212696/why-doesnt-perl-6s-colon-pair-and-name-interpolation-work-together

Expected these two versions to be equivalent:

$ ./perl6 -e 'my $foo = "bar"; my %bar = :42foo, :70bar; dd [$foo => %::($foo)]'
[:bar({:bar(70), :foo(42)})]

$ ./perl6 -e 'my $foo = "bar"; my %bar = :42foo, :70bar; dd [:%::($foo)]'
===SORRY!=== Error while compiling -e
Variable '%::($foo)' is not declared
at -e:1
------> = "bar"; my %bar = :42foo, :70bar; dd [:⏏%::($foo)]

$ ./perl6 -v
This is Rakudo version 2018.01-204-gbeaad7b built on MoarVM version 2018.01-94-gc7774e3
implementing Perl 6.c.

The %::($foo) construct is already parsed as a variable and colonpairs can handle them, but looks like the colonpair token simply assumes it can strigify the Match of the variable to get its name: $<var><desigilname>.Str

@zoffixznet zoffixznet self-assigned this Feb 16, 2018
@jnthn
Copy link
Member

@jnthn jnthn commented Feb 16, 2018

One thing to be aware of: :$foo is a named parameter in the context of an argument list, and we need to know our named parameter names at compile time.

@JJ
Copy link
Collaborator

@JJ JJ commented Jul 17, 2020

If I understand this correctly, there's no fix, but we could improve the documentation to reflect that named parameter names need to be known at compile time, right?

@Altai-man
Copy link
Member

@Altai-man Altai-man commented Jul 17, 2020

No, it is a legitimate bug we should address and move forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.