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 enum element in another module causes null PMC access #772

Closed
p6rt opened this issue Mar 12, 2009 · 7 comments
Closed

Accessing enum element in another module causes null PMC access #772

p6rt opened this issue Mar 12, 2009 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Mar 12, 2009

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

Searchable as RT63826$

@p6rt
Copy link
Author

p6rt commented Mar 12, 2009

From @mathw

[matthew@​asymptote form]$ perl6 -e "module M { enum E <a b> }; M​::E​::a"
Null PMC access in invoke()
current instr.​: '_block20' pc 60 (EVAL_24​:39)
called from Sub '!UNIT_START' pc 17340 (src/builtins/guts.pir​:325)
called from Sub 'parrot;PCT;HLLCompiler;eval' pc 950
(src/PCT/HLLCompiler.pir​:527)
called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1496
(src/PCT/HLLCompiler.pir​:787)
called from Sub 'parrot;Perl6;Compiler;main' pc 21637 (perl6.pir​:163)

@p6rt
Copy link
Author

p6rt commented Mar 14, 2009

From @masak

<jnthn> masak​: Rather too many tickets than too few.
<masak> that's, like, my motto.
<bacek> rakudo​: package Foo { enum A <a>; }; say a;
<p6eval> rakudo 5b1ff9​: OUTPUT«Could not find non-existent sub a [...]
<bacek> rakudo​: package Foo { enum A <a>; }; say Foo​::A​::a;
<p6eval> rakudo 5b1ff9​: OUTPUT«Null PMC access in invoke() [...]
<bacek> yak...
<masak> new bug?
<bacek> masak​: not sure.
<masak> let me know when you're sure. :)
<bacek> but... Use your motto :)
* masak uses his motto

@p6rt
Copy link
Author

p6rt commented Jul 27, 2009

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S02-builtin_data_types/enum.t

commit 38295f658dd60105e7564f6101d89f08304cd0e9
Author​: kyle <kyle@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Mon Jul 27 15​:36​:39 2009 +0000

  [t/spec] Test for RT #​63826
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;27754 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S02-builtin_data_types/enum.t b/t/spec/S02-builtin_data_types/enum.t
index e7e71bf..5a78959 100644
--- a/t/spec/S02-builtin_data_types/enum.t
+++ b/t/spec/S02-builtin_data_types/enum.t
@@ -2,7 +2,7 @@ use v6;
 
 use Test;
 
-plan 30;
+plan 40;
 # L<S12/Enums>
 {
     my %hash; eval '%hash = enum «:Mon(1) Tue Wed Thu Fri Sat Sun»';
@@ -108,3 +108,35 @@ is %hash.values, (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F'), '
 
 %hash = ();
 
+# RT #63826
+{
+    class EnumClass     { enum C <a b c> }
+    #?rakudo todo 'RT #63826'
+    lives_ok { EnumClass::C::a }, 'can refer to enum element in class';
+    #?rakudo skip 'RT #63826'
+    is EnumClass::C::a, 0, 'enum element in class has the right value';
+
+    module EnumModule   { enum M <a b c> }
+    #?rakudo todo 'RT #63826'
+    lives_ok { EnumModule::M::a }, 'can refer to enum element in module';
+    #?rakudo skip 'RT #63826'
+    is EnumModule::M::b, 1, 'enum element in module has the right value';
+
+    package EnumPackage { enum P <a b c> }
+    #?rakudo todo 'RT #63826'
+    lives_ok { EnumPackage::P::a }, 'can refer to enum element in package';
+    #?rakudo skip 'RT #63826'
+    is EnumPackage::P::c, 2, 'enum element in package has the right value';
+
+    role EnumRole       { enum R <a b c> }
+    #?rakudo todo 'RT #63826'
+    lives_ok { EnumRole::R::a }, 'can refer to enum element in role';
+    #?rakudo skip 'RT #63826'
+    is EnumRole::R::a, 0, 'enum element in role has the right value';
+
+    grammar EnumGrammar { enum G <a b c> }
+    #?rakudo todo 'RT #63826'
+    lives_ok { EnumGrammar::G::a }, 'can refer to enum element in grammar';
+    #?rakudo skip 'RT #63826'
+    is EnumGrammar::G::b, 1, 'enum element in grammar has the right value';
+}

@p6rt
Copy link
Author

p6rt commented Jul 27, 2009

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

@p6rt
Copy link
Author

p6rt commented Jul 12, 2010

From @bbkr

On head build (past Kiev) it's​:

[15​:39] <bbkr> rakudo​: module M { enum E <a b> }; M​::E​::a;
[15​:39] <p6eval> rakudo bb6df2​: OUTPUT«Can not find sub M​::E​::a␤ in
main program body at line 1␤»

@p6rt
Copy link
Author

p6rt commented Sep 24, 2011

From @moritz

In nom, the Null PMC access is gone, and the tests (now in
S12-enums/misc.t) pass, so closing this ticket. Thanks.

@p6rt
Copy link
Author

p6rt commented Sep 24, 2011

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

@p6rt p6rt closed this as completed Sep 24, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant