On Thu Apr 21 12:34:10 2016, barto...@gmx.de wrote:
> On Thu Apr 21 11:53:14 2016, barto...@gmx.de wrote:
> >
> > $ perl6-j -e 'say < 8+9i >.re'
> > Attribute '$!re' is not a native num
> >   in block <unit> at -e line 1
> 
> Oh, looks like rakudo-j has other problems with the attributes of
> ComplexStr:
> 
> $ perl6-j 'say < 8+9i >.im'
> 8

The problem here lies somewhere in the generation of the accessors for Complex. 
 We apparently cache the getattr hint for the Attributes in Complex and reuse 
them whenever we call the generated accessor, which results in an off-by-one 
error when we call the same generated accessors on a ComplexStr.  Perl 6-level 
workaround would be to turn $.re and $.im in Complex into $!re and $!im and 
supplying an explicit accessor.  Fixing this inside nqp-j probably involves a 
lot of figuring out where and how attribute hints are cached.

Note that the same problem doesn't occur with IntStr or NumStr because they 
don't have auto-generated accessors, and RatStr gets its accessors from the 
role Rational, which probably gets composed differently and thus avoids the 
issue.  I'm not sure about the details there, to be honest.

Reply via email to