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

Accessing global variable in a class results in Null PMC access #734

Closed
p6rt opened this issue Mar 2, 2009 · 11 comments
Closed

Accessing global variable in a class results in Null PMC access #734

p6rt opened this issue Mar 2, 2009 · 11 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Mar 2, 2009

Migrated from rt.perl.org#63588 (status was 'resolved')

Searchable as RT63588$

@p6rt
Copy link
Author

p6rt commented Jan 14, 2009

From @masak

<masak> rakudo​: my $x = "foo"; class A { my $.y = $x } # bug?
<p6eval> rakudo 35518​: OUTPUT«Lexical '$x' not found␤ [...]
<masak> rakudo​: our $x = "foo"; class A { my $.y = $x }
<p6eval> rakudo 35519​: OUTPUT«Null PMC access in isa() [...]
<masak> :(
* masak submits rakudobug

@p6rt
Copy link
Author

p6rt commented Jan 16, 2009

From @pmichaud

On Wed, Jan 14, 2009 at 01​:28​:10AM -0800, Carl Mäsak wrote​:

<masak> rakudo​: my $x = "foo"; class A { my $.y = $x } # bug?
<p6eval> rakudo 35518​: OUTPUT«Lexical '$x' not found␤ [...]

There's a known problem that we can't yet do outer lexicals from
things that look like BEGIN blocks (in Parrot terms -- things that
happen at :load :init time). I don't know when/how this will
be fixed.

<masak> rakudo​: our $x = "foo"; class A { my $.y = $x }
<p6eval> rakudo 35519​: OUTPUT«Null PMC access in isa() [...]

Since the body of class declarations happens at BEGIN time, the
initialization of $y is occurring before $x is initialized
(or even vivified). Granted, Rakudo should not be generating
the Null PMC access message, but I also wouldn't expect $.y
to be initialized to 'foo'.

Pm

@p6rt
Copy link
Author

p6rt commented Jan 16, 2009

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

@p6rt
Copy link
Author

p6rt commented Mar 2, 2009

From @moritz

Rakudo 08b789048​:

./perl6 -e 'our $x; class Foo { $x = 3 }; say $x'
Null PMC access in getprop()
current instr.​: 'infix​:=' pc 14554 (src/builtins/assign.pir​:21)
called from Sub 'parrot;Foo;_block21' pc 126 (EVAL_20​:58)

--
Moritz Lenz
http://perlgeek.de/ | http://perl-6.de/ | http://sudokugarden.de/

@p6rt
Copy link
Author

p6rt commented Mar 17, 2009

From @jnthn

On Mon Mar 02 01​:01​:32 2009, mlenz@​physik.uni-wuerzburg.de wrote​:

Rakudo 08b789048​:

./perl6 -e 'our $x; class Foo { $x = 3 }; say $x'
Null PMC access in getprop()
current instr.​: 'infix​:=' pc 14554 (src/builtins/assign.pir​:21)
called from Sub 'parrot;Foo;_block21' pc 126 (EVAL_20​:58)

Ah, that'll likely be because $x = 3 gets run before the our $x...

Jonathan

@p6rt
Copy link
Author

p6rt commented Mar 17, 2009

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

@p6rt
Copy link
Author

p6rt commented Mar 27, 2010

From robert_strahl@yahoo.com

On Mon Mar 02 01​:01​:32 2009, mlenz@​physik.uni-wuerzburg.de wrote​:

Rakudo 08b789048​:

./perl6 -e 'our $x; class Foo { $x = 3 }; say $x'
Null PMC access in getprop()
current instr.​: 'infix​:=' pc 14554 (src/builtins/assign.pir​:21)
called from Sub 'parrot;Foo;_block21' pc 126 (EVAL_20​:58)

This portion works​:
perl6 -e 'our $x; class Foo { $x = 3 }; say $x'
3

but the other part, not yet​:
perl6 -e 'my $x = 3; class A { has $.y = $x }; say A.new.y'
Lexical '$x' not found

@p6rt
Copy link
Author

p6rt commented Jun 12, 2010

From radu_cs85@yahoo.com

Added test in t/spec/S04-declarations/my.t.

@p6rt
Copy link
Author

p6rt commented Jun 30, 2010

From @bbkr

On Kiev build​:

[12​:05] <bbkr> rakudo​: my $x = "foo"; class A { my $.y = $x }
[12​:05] <p6eval> rakudo 36998b​: ( no output )

But...

[12​:07] <jnthn> bbkr​: We don't do anything with my $.foo yet in Rakudo afaik

@p6rt
Copy link
Author

p6rt commented Jan 31, 2011

From @felliott

Hello,

This is working in current rakudo and is passing the relevant test. I'm
marking this resolved.

Cheers,
Fitz Elliott

@p6rt
Copy link
Author

p6rt commented Jan 31, 2011

@felliott - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jan 31, 2011
@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