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

Null PMC Access when calling a sub &foo with a parameter &foo defaulting to &foo in Rakudo #1174

Closed
p6rt opened this issue Jul 27, 2009 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jul 27, 2009

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

Searchable as RT67932$

@p6rt
Copy link
Author

p6rt commented Jul 27, 2009

From @masak

<masak> rakudo​: sub foo(&foo = &foo) { say "OH HAI"; foo }; foo
<p6eval> rakudo 4c31fb​: OUTPUT«Null PMC access in isa()␤in sub foo [...]
<hoelzro> pmichaud​: it should just alert you
<masak> hah!
* masak submits rakudobug
<masak> rakudo​: sub foo(&foo = &foo) {}; foo
<p6eval> rakudo 4c31fb​: OUTPUT«Null PMC access in isa()␤in sub foo [...]
<moritz_> rakudo​: sub foo(&foo = &foo) {};
<p6eval> rakudo 4c31fb​: ( no output )
<moritz_> ah, happens while calling
<masak> aye.
<KyleHa> Is that supposed to live?
<masak> I think so.
<masak> KyleHa​: the first &foo is the param, the second is the sub.

@p6rt
Copy link
Author

p6rt commented Apr 19, 2010

From @jnthn

On Mon Jul 27 08​:11​:54 2009, masak wrote​:

<masak> rakudo​: sub foo(&foo = &foo) { say "OH HAI"; foo }; foo
<p6eval> rakudo 4c31fb​: OUTPUT«Null PMC access in isa()␤in sub foo [...]
<hoelzro> pmichaud​: it should just alert you
<masak> hah!
* masak submits rakudobug
<masak> rakudo​: sub foo(&foo = &foo) {}; foo
<p6eval> rakudo 4c31fb​: OUTPUT«Null PMC access in isa()␤in sub foo [...]
<moritz_> rakudo​: sub foo(&foo = &foo) {};
<p6eval> rakudo 4c31fb​: ( no output )
<moritz_> ah, happens while calling
<masak> aye.
<KyleHa> Is that supposed to live?
<masak> I think so.
<masak> KyleHa​: the first &foo is the param, the second is the sub.

It now lives​:

00​:30 <@​jnthn> rakudo​: sub foo(&foo = &foo) {}; foo
00​:30 <+p6eval> rakudo 346e76​: ( no output )

Since the &foo inside the sub is a new lexical variable, you essentially
end up doing like my $a = $a which is fine but useless...

00​:30 <@​jnthn> rakudo​: sub foo(&foo = &foo) {say &foo}; foo
00​:30 <+p6eval> rakudo 346e76​: OUTPUT«Any()␤»

Anyway, it's what I'd expect. Giving to moritz++ for spectest.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Apr 19, 2010

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

@p6rt
Copy link
Author

p6rt commented Apr 21, 2010

From @moritz

Tested in S06-signature/code.t.

@p6rt
Copy link
Author

p6rt commented Apr 21, 2010

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

@p6rt p6rt closed this as completed Apr 21, 2010
@p6rt
Copy link
Author

p6rt commented Apr 22, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S06-signature/code.t

commit 6d18247f0f0e02ee8084016b843522245cc6c5bb
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Wed Apr 21 20​:30​:51 2010 +0000

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

Inline Patch
diff --git a/t/spec/S06-signature/code.t b/t/spec/S06-signature/code.t
index 9a54662..733970b 100644
--- a/t/spec/S06-signature/code.t
+++ b/t/spec/S06-signature/code.t
@@ -1,6 +1,6 @@
 use v6;
 use Test;
-plan 6;
+plan 8;
 
 # TODO: move this test to closure-parameters.t if it works in the future
 
@@ -37,4 +37,15 @@ is tester2({ 'block' }), 1, 'Can pass a block to a &parameter';
             "Can't pass something that isn't typed as returning Callable";
 }
 
+# RT #67932
+{
+    my $tracker;
+    sub foo(&foo = &foo) {
+        $tracker = &foo
+    };
+    lives_ok { foo },
+        'can call a sub with a code object defaulting to something of its own name';
+    ok !$tracker.defined, 'the inner &foo is undefined (scoping)';
+}
+
 # vim: ft=perl6

@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