#1512: NQP-rx generates bad access code for non-twigiled attribute
-----------------------------+----------------------------------------------
Reporter: Austin_Hastings | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: none | Version: 2.1.0
Severity: medium | Keywords:
Lang: | Patch:
Platform: |
-----------------------------+----------------------------------------------
This code, with twigil:
{{{
aus...@andlinux:~/kakapo$ cat test.nqp
method foo() {
has @!attr;
for my @a {
say(@!attr);
}
}
}}}
Generates this pir:
{{{
.annotate "line", 5
find_lex $P24, "self"
getattribute $P25, $P24, "@!attr"
unless_null $P25, vivify_14
new $P25, "ResizablePMCArray"
vivify_14:
}}}
Whereas this code, sans twigil:
{{{
aus...@andlinux:~/kakapo$ cat test.nqp
method foo() {
has @attr;
for my @a {
say(@attr);
}
}
}}}
Generates this output:
{{{
.annotate "line", 5
getattribute $P24, self, "@attr"
$P25 = "say"($P24)
.annotate "line", 4
}}}
Because the sub is a nested block, it has no method declaration and so
must do a find-lex lookup to get 'self'. This is not happening.
Since the grammar does not support '.' as a twigil, which I think it
should, I'm not sure if an attribute with no twigil is or isn't valid. If
it's not valid, then the `has @attr` declaration should throw an error. If
it's valid, then the access code should work.
--
Ticket URL: <https://trac.parrot.org/parrot/ticket/1512>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets