Skip Menu |
Report information
Id: 131122
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: david.warring <david.warring [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Date: Sat, 8 Apr 2017 14:01:53 +1200
Subject: [BUG] unsigned native ints not applied in class attributes
From: David Warring <david.warring [...] gmail.com>
To: rakudobug [...] perl.org
Download (untitled) / with headers
text/plain 445b
Consider
class C {
    has uint8 $.ff;
}
my $c = C.new(ff => 255);
say $c.perl;
say $c.ff;

class C2 is repr('CStruct') {
    has uint8 $.ff is rw;
}

my $c2 = C2.new;
$c2.ff = 200;
say $c2.ff;
Produces
C.new(ff => -1)
-1
-56
Both classes produce signed results, for the 'ff' attribute, declared as uint8.
david@X346:~$ perl6 -v
This is Rakudo version 2017.03-174-gd793e21 built on MoarVM version 2017.03-98-g9653dc6
implementing Perl 6.c.

Hm. There are several tickets like this.

Possibly related tickets:
#RT 124088
#RT 127144
#RT 127210
#RT 124294
#RT 130267

Should we link them all together?

On 2017-04-07 19:02:23, david.warring wrote:
Show quoted text
> Consider
>
> class C {
> has uint8 $.ff;
> }
> my $c = C.new(ff => 255);
> say $c.perl;
> say $c.ff;
>
> class C2 is repr('CStruct') {
> has uint8 $.ff is rw;
> }
>
> my $c2 = C2.new;
> $c2.ff = 200;
> say $c2.ff;
>
> Produces
>
> C.new(ff => -1)
> -1
> -56
>
> Both classes produce signed results, for the 'ff' attribute, declared
> as uint8.
>
> david@X346:~$ perl6 -v
> This is Rakudo version 2017.03-174-gd793e21 built on MoarVM version
> 2017.03-98-g9653dc6
> implementing Perl 6.c.


Download (untitled) / with headers
text/plain 866b
+1 Look related. On Fri, 07 Apr 2017 19:19:19 -0700, alex.jakimenko@gmail.com wrote: Show quoted text
> Hm. There are several tickets like this. > > Possibly related tickets: > #RT 124088 > #RT 127144 > #RT 127210 > #RT 124294 > #RT 130267 > > Should we link them all together? > > On 2017-04-07 19:02:23, david.warring wrote:
> > Consider > > > > class C { > > has uint8 $.ff; > > } > > my $c = C.new(ff => 255); > > say $c.perl; > > say $c.ff; > > > > class C2 is repr('CStruct') { > > has uint8 $.ff is rw; > > } > > > > my $c2 = C2.new; > > $c2.ff = 200; > > say $c2.ff; > > > > Produces > > > > C.new(ff => -1) > > -1 > > -56 > > > > Both classes produce signed results, for the 'ff' attribute, declared > > as uint8. > > > > david@X346:~$ perl6 -v > > This is Rakudo version 2017.03-174-gd793e21 built on MoarVM version > > 2017.03-98-g9653dc6 > > implementing Perl 6.c.
I've added some tests to S12-attributes/native.t, based on these test cases. On Fri, 07 Apr 2017 19:31:22 -0700, david.warring wrote: Show quoted text
> +1 Look related. > > On Fri, 07 Apr 2017 19:19:19 -0700, alex.jakimenko@gmail.com wrote:
> > Hm. There are several tickets like this. > > > > Possibly related tickets: > > #RT 124088 > > #RT 127144 > > #RT 127210 > > #RT 124294 > > #RT 130267 > > > > Should we link them all together? > > > > On 2017-04-07 19:02:23, david.warring wrote:
> > > Consider > > > > > > class C { > > > has uint8 $.ff; > > > } > > > my $c = C.new(ff => 255); > > > say $c.perl; > > > say $c.ff; > > > > > > class C2 is repr('CStruct') { > > > has uint8 $.ff is rw; > > > } > > > > > > my $c2 = C2.new; > > > $c2.ff = 200; > > > say $c2.ff; > > > > > > Produces > > > > > > C.new(ff => -1) > > > -1 > > > -56 > > > > > > Both classes produce signed results, for the 'ff' attribute, declared > > > as uint8. > > > > > > david@X346:~$ perl6 -v > > > This is Rakudo version 2017.03-174-gd793e21 built on MoarVM version > > > 2017.03-98-g9653dc6 > > > implementing Perl 6.c.
> >


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org