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

Calling undefine twice in sequence causes "Null PMC in copy" #1299

Closed
p6rt opened this issue Sep 19, 2009 · 8 comments
Closed

Calling undefine twice in sequence causes "Null PMC in copy" #1299

p6rt opened this issue Sep 19, 2009 · 8 comments
Labels
Bug LHF Low-hanging fruit, easy to resolve

Comments

@p6rt
Copy link

p6rt commented Sep 19, 2009

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

Searchable as RT69238$

@p6rt
Copy link
Author

p6rt commented Aug 31, 2009

From @carbin

Also occurs with methods etc.

sub foo { my $a = "baz"; undefine $a; }; say foo;
Null PMC access in type()
in Main (<unknown>​:1)

--
Carlin

@p6rt
Copy link
Author

p6rt commented Sep 19, 2009

From @carbin

On a side note, it looks like there are inconsistencies in the Null
PMC access error messages ;-)

23​:22 < carlin> rakudo​: sub foo {}; undefine undefine foo;
23​:22 <+p6eval> rakudo 0d77e4​: OUTPUT«Null PMC in copy␤»

--
Carlin

@p6rt
Copy link
Author

p6rt commented Sep 19, 2009

From @carbin

More undefined silliness :-)

04​:31 < carlin> rakudo​: sub foo($bar) { say $bar }; my $x = 'x';
foo(undefine $x);
04​:31 <+p6eval> rakudo 0d77e4​: OUTPUT«Null PMC access in isa()␤in sub foo
  (/tmp/MFiaifDhR7​:2)␤called from Main (/tmp/MFiaifDhR7​:2)␤»

--
Carlin

@p6rt
Copy link
Author

p6rt commented Sep 26, 2009

From jswitzer@gmail.com

This patch should move undefine to the setting, providing both the multi
method and the multi sub. Note that the is export is not working in
aliased classes. If that is fixed, remove the multi sub and add is
export to the multi method.

-Jason "s1n" Switzer

@p6rt
Copy link
Author

p6rt commented Sep 26, 2009

From jswitzer@gmail.com

undefine.patch
diff --git a/src/builtins/named-unary.pir b/src/builtins/named-unary.pir
index 6d67a70..ca82b6d 100644
--- a/src/builtins/named-unary.pir
+++ b/src/builtins/named-unary.pir
@@ -45,19 +45,6 @@ Returns a true value if $x is defined, and a false value otherwise.
 .end
 
 
-=item undefine $x
-
-Sets $x to an undefined value
-
-=cut
-
-.sub 'undefine'
-    .param pmc x
-    $P0 = root_new ['parrot';'Perl6Scalar']
-    copy x, $P0
-.end
-
-
 =back
 
 =cut
diff --git a/src/setting/Object.pm b/src/setting/Object.pm
index b406657..7e3b54a 100644
--- a/src/setting/Object.pm
+++ b/src/setting/Object.pm
@@ -73,6 +73,14 @@ class Object is also {
 
         return @methods;
     }
+
+    multi method undefine() {
+        self = undef;
+    }
+}
+
+multi sub undefine($x) {
+    $x.undefine;
 }
 
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Sep 26, 2009

jswitzer@gmail.com - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Apr 4, 2010

From @moritz

I'm not sure if the patch attached to this ticket ever got applied, but
undefine() now lives in the setting, there's no Null PMC access anymore,
and there's a test in S32-scalar/undef.t -- so all in all nothing
prevents me from closing this ticket for good :-).

@p6rt
Copy link
Author

p6rt commented Apr 4, 2010

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

@p6rt p6rt closed this as completed Apr 4, 2010
@p6rt p6rt added Bug LHF Low-hanging fruit, easy to resolve labels Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug LHF Low-hanging fruit, easy to resolve
Projects
None yet
Development

No branches or pull requests

1 participant