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

The same class-wide variable, accessed two different ways, behaves like two different variables in Rakudo #1478

Closed
p6rt opened this issue Jan 24, 2010 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jan 24, 2010

Migrated from rt.perl.org#72326 (status was 'rejected')

Searchable as RT72326$

@p6rt
Copy link
Author

p6rt commented Jan 24, 2010

From @masak

This be Rakudo db84bc on Parrot r43174.

$ perl6 -e 'class A​::B { my $c; method foo { $c = "OH HAI"; say $c }
}; A​::B.foo'
OH HAI

$ perl6 -e 'class A​::B { my $c; method foo { $A​::B​::c = "OH HAI"; say
$A​::B​::c } }; A​::B.foo'
OH HAI

Fair enough. So far Rakudo agrees with my expectations. But watch this​:

$ perl6 -e 'class A​::B { my $c = 42; method foo { $A​::B​::c = "OH HAI";
say $c } }; A​::B.foo'
42

$ perl6 -e 'class A​::B { my $c = 42; method foo { $c = "OH HAI"; say
$A​::B​::c } }; A​::B.foo'
Use of uninitialized value

Ok, so in the first case we set $A​::B​::c and $c is unaffected. I'd
expect it to change, since it's really the same memory
location/slot/whatever.

In the second case, we set $c and $A​::B​::c is unaffected. Furthermore,
$A​::B​::c isn't even initialized to 42 in this case, even though
$A​::B​::c should only be a longer way of saying $c (inside the A​::B
scope).

@p6rt
Copy link
Author

p6rt commented Mar 9, 2010

From @moritz

On Sun Jan 24 10​:01​:53 2010, masak wrote​:

This be Rakudo db84bc on Parrot r43174.

$ perl6 -e 'class A​::B { my $c; method foo { $c = "OH HAI"; say $c }
}; A​::B.foo'
OH HAI

$ perl6 -e 'class A​::B { my $c; method foo { $A​::B​::c = "OH HAI"; say
$A​::B​::c } }; A​::B.foo'
OH HAI

Fair enough. So far Rakudo agrees with my expectations. But watch this​:

$ perl6 -e 'class A​::B { my $c = 42; method foo { $A​::B​::c = "OH HAI";
say $c } }; A​::B.foo'
42

Now says

Null PMC access in getprop()
current instr.​: '&infix​:<=>' pc 16638 (src/builtins/Junction.pir​:228)
called from Sub 'perl6;A;B;foo' pc 202 (EVAL_1​:96)

Not sure that's an improvement :-)

@p6rt
Copy link
Author

p6rt commented Mar 9, 2010

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 13, 2011

From @bbkr

NOM​: still broken

bbkr​:nom bbkr$ ./perl6 -e 'class A​::B { my $c; method foo { $c = "OH
HAI"; say $c } }; A​::B.foo'
OH HAI

bbkr​:nom bbkr$ ./perl6 -e 'class A​::B { my $c; method foo { $A​::B​::c =
"OH HAI"; say $A​::B​::c } }; A​::B.foo'
OH HAI

bbkr​:nom bbkr$ ./perl6 -e 'class A​::B { my $c = 42; method foo {
$A​::B​::c = "OH HAI"; say $c } }; A​::B.foo'
42

@p6rt
Copy link
Author

p6rt commented Aug 5, 2012

From @masak

<masak> r​: class A​::B { my $c = 42; method foo { $A​::B​::c = "OH HAI"; say
$c } }; A​::B.foo
<p6eval> rakudo 0eea68​: OUTPUT«42␤»
<masak> r​: class A​::B { my $c = 42; method foo { $c = "OH HAI"; say
$A​::B​::c } }; A​::B.foo
<p6eval> rakudo 0eea68​: OUTPUT«Any()␤»
<masak> the former one is fine, I guess. at least if package stashes can
be extended like that.
<masak> the latter one is, hm, also fine.
* masak rejects https://rt-archive.perl.org/perl6/Ticket/Display.html?id=72326

The original ticket seems to stem from a confusion between my-scoped and
our-scoped variables, and the containers they share. I see nothing
unexpected in the above. Rejecting ticket.

@p6rt
Copy link
Author

p6rt commented Aug 5, 2012

@masak - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Aug 5, 2012
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant