[perl #129278] [BUG] Can't assign to `int` private attribute using signature

2016-11-23 Thread Christian Bartolomaeus via RT
On Tue, 18 Oct 2016 08:39:21 -0700, barto...@gmx.de wrote:
> 
> Again, for the records: lizmat++ put in a bandaid for rakudo-j with
> Rakudo commit 666128fc6e. The tests from S32-list/head.t run fine, but
> the underlying problem is still there.

The bandaid was remove recently (Rakudo commit e8f938b0f6) after psch++ 
implemented attribute parameter binding on the JVM.

So we are back to what jnthn said about roles or more complex signatures:

On Wed, 21 Sep 2016 06:30:00 -0700, jn...@jnthn.net wrote:
> I've fixed this and added tests to S12-methods/attribute-params.t. It
> works for named parameters too. So in terms of the originally reported
> issue this ticket could be considered done.
> 
> But.
> 
> Unfortunately, the moment you have a role instead of a class, or a a
> more complex signature (for example, involving an unpack), it fails.
> So, some more work and tests needed.


[perl #129278] [BUG] Can't assign to `int` private attribute using signature

2016-10-18 Thread Christian Bartolomaeus via RT
On Sat Oct 15 00:31:09 2016, barto...@gmx.de wrote:
> [...]
> Tests that use the new method SeqNextNFromIterator fail due to this
> problem. From S32-list/head.t:

Again, for the records: lizmat++ put in a bandaid for rakudo-j with Rakudo 
commit 666128fc6e. The tests from S32-list/head.t run fine, but the underlying 
problem is still there.


[perl #129278] [BUG] Can't assign to `int` private attribute using signature

2016-10-15 Thread Christian Bartolomaeus via RT
For the records: This fails on JVM (has to be fixed in 
src/vm/jvm/runtime/org/perl6/rakudo/Binder.java, probabaly):

$ ./perl6-j -e 'class { has int $!n = 0; method x ($!n) {} }.new.x: 42'
org.perl6.nqp.sixmodel.reprs.P6OpaqueBaseInstance$BadReferenceRuntimeException: 
Cannot access a native attribute as a reference attribute
  in method x at -e line 1
  in block  at -e line 1

Tests that use the new method SeqNextNFromIterator fail due to this problem. 
From S32-list/head.t:

$ ./perl6-j -e 'my $list = ; say $list.head(3)'
org.perl6.nqp.sixmodel.reprs.P6OpaqueBaseInstance$BadReferenceRuntimeException: 
Cannot access a native attribute as a reference attribute
  in block  at -e line 1

This works, if one doesn't use a native here: 
https://github.com/rakudo/rakudo/blob/2c681c55520d34750663cdec2fefcf3005ee550e/src/core/Rakudo/Internals.pm#L266


[perl #129278] [BUG] Can't assign to `int` private attribute using signature

2016-09-21 Thread jn...@jnthn.net via RT
On Thu Sep 15 11:49:35 2016, c...@zoffix.com wrote:
> #Doesn't work:
>  m: class { has int $!n = 0; method x ($!n) {} }.new.x: 42
>  rakudo-moar 2c95f7: OUTPUT«Cannot modify an immutable int␤
> in method x at  line 1␤  in block  at  line 1␤␤»
> 
I've fixed this and added tests to S12-methods/attribute-params.t. It works for 
named parameters too. So in terms of the originally reported issue this ticket 
could be considered done.

But.

Unfortunately, the moment you have a role instead of a class, or a a more 
complex signature (for example, involving an unpack), it fails. So, some more 
work and tests needed.



Re: [perl #129278] [BUG] Can't assign to `int` private attribute using signature

2016-09-15 Thread Elizabeth Mattijsen
This is a known issue, as there is no native support for attribute binding this 
way.  There’s quite some code in the setting working around this issue  :-(

> On 15 Sep 2016, at 20:49, Zoffix Znet (via RT)  
> wrote:
> 
> # New Ticket Created by  Zoffix Znet 
> # Please include the string:  [perl #129278]
> # in the subject line of all future correspondence about this issue. 
> # https://rt.perl.org/Ticket/Display.html?id=129278 >
> 
> 
> #Doesn't work:
>  m: class { has int $!n = 0; method x ($!n) {} }.new.x: 42
>  rakudo-moar 2c95f7: OUTPUT«Cannot modify an immutable int␤  in 
> method x at  line 1␤  in block  at  line 1␤␤»
> 
> # But does, if we use a temp var:
>  m: class { has int $!n = 0; method x ($n) {$!n = $n} }.new.x: 42
>  rakudo-moar 2c95f7: ( no output )


[perl #129278] [BUG] Can't assign to `int` private attribute using signature

2016-09-15 Thread via RT
# New Ticket Created by  Zoffix Znet 
# Please include the string:  [perl #129278]
# in the subject line of all future correspondence about this issue. 
# https://rt.perl.org/Ticket/Display.html?id=129278 >


#Doesn't work:
 m: class { has int $!n = 0; method x ($!n) {} }.new.x: 42
 rakudo-moar 2c95f7: OUTPUT«Cannot modify an immutable int␤  in method 
x at  line 1␤  in block  at  line 1␤␤»

# But does, if we use a temp var:
 m: class { has int $!n = 0; method x ($n) {$!n = $n} }.new.x: 42
 rakudo-moar 2c95f7: ( no output )