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

Defining and calling a method in a grammar causes Null PMC access in find_method() #1295

Closed
p6rt opened this issue Sep 19, 2009 · 5 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 19, 2009

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

Searchable as RT69228$

@p6rt
Copy link
Author

p6rt commented Sep 19, 2009

From @carbin

I am not sure if this is supposed to work or not but the NPMCA is
obviously not ideal

grammar foo { rule TOP { 'lorem' | <.panic> }; method panic { die "The sky is falling!"; }; }; foo.parse('blah');
Null PMC access in find_method()
in method foo​::panic (<unknown>​:1)
called from regex foo​::TOP (<unknown>​:1)

<carlin> rakudo​: grammar foo { rule TOP { 'lorem' | <.panic> }; method
panic { die "The sky is falling!"; }; }; foo.parse('blah');
<p6eval> rakudo 4b141a​: OUTPUT«Null PMC access in find_method()␤in
method foo​::panic (/tmp/DbgEqS8ZnV​:2)␤called from regex foo​::TOP
(/tmp/DbgEqS8ZnV​:2)␤called from Main (/tmp/DbgEqS8ZnV​:2)␤»

--
Carlin

@p6rt
Copy link
Author

p6rt commented Oct 20, 2009

From @moritz

10​:39 < carlin> rakudo​: grammar foo { rule TOP { 'lorem' | <.panic> };
method
  panic { die "The sky is falling!"; }; };
foo.parse('blah'); #
  RT 69228
10​:39 <+p6eval> rakudo 9d76f3​: OUTPUT«The sky is falling!␤in method
foo​::panic
10​:40 <@​tinita> (file /tmp/20eC7h2q0n, line 2)␤called from regex
foo​::TOP (file
  /tmp/20eC7h2q0n, line 2)␤called from Main (file
<unknown>, line
  <unknown>)␤»
10​:40 <@​moritz_> carlin​: so barring test coverage that can be closed?
10​:41 < carlin> moritz_​: yep, not an NPMCA anymore

@p6rt
Copy link
Author

p6rt commented Oct 20, 2009

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

@p6rt
Copy link
Author

p6rt commented Oct 20, 2009

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S05-grammar/methods.t

commit 1304265c541f9a396febab7315706dff5cef6af6
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Tue Oct 20 20​:45​:18 2009 +0000

  [t/spec] tests for RT #​69228, calling methods from a grammar
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;28860 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S05-grammar/methods.t b/t/spec/S05-grammar/methods.t
new file mode 100644
index 0000000..6da2f7d
--- /dev/null
+++ b/t/spec/S05-grammar/methods.t
@@ -0,0 +1,17 @@
+use v6;
+use Test;
+
+plan *;
+
+grammar WithMethod {
+    rule TOP { 'lorem' | <.panic> }
+    method panic { die "The sky is falling!"; }
+};
+
+dies_ok { WithMethod.parse('unrelated') },
+   'Can call die() from a method within a grammar';
+
+try { WithMethod.parse('unrelated') };
+ok "$!" ~~ /'The sky is falling!'/, 'and got the exception message';
+
+done_testing;

@p6rt
Copy link
Author

p6rt commented Oct 20, 2009

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

@p6rt p6rt closed this as completed Oct 20, 2009
@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