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 multi sub with a parameter narrowed by a subtype that does a regex match in Rakudo #2194

Open
p6rt opened this issue Oct 7, 2010 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 7, 2010

Migrated from rt.perl.org#78276 (status was 'open')

Searchable as RT78276$

@p6rt
Copy link
Author

p6rt commented Oct 7, 2010

From @masak

<masak> rakudo​: subset Greeting of Str where { /​:i ^oh \s+ \w+ '!'?$/
}; subset LolGreeting of Str where { .words[1].lc eq 'hai' }; multi
detect(Str) { "not a greeting" }; multi detect(Greeting) { "regular
greeting" }; multi detect(LolGreeting) { "lol-greeting" }; say detect
"OH HAI"
<p6eval> rakudo e9e7fc​: OUTPUT«Null PMC access in isa_pmc() [....]
* masak submits rakudobug
<ash_> rakudo​: say 'foo' ~~ /​:i foo/;
<p6eval> rakudo e9e7fc​: OUTPUT«foo␤»
<masak> ash_​: it's to do with multies, and subtypes.
<ash_> got ya
<masak> rakudo​: subset G of Str where { /O/ }; sub detect(G) {}; detect "O"
<p6eval> rakudo e9e7fc​: OUTPUT«Method 'match' not found for invocant
of class ' [...]
<masak> rakudo​: subset G of Str where { /O/ }; multi detect(G) {}; detect "O"
<p6eval> rakudo e9e7fc​: OUTPUT«Null PMC access in isa_pmc()␤ in
'&infix​:<=>' at line 1␤ in 'Regex​::Bool' at line 5970​:CORE.setting␤
in 'detect' [...]
<masak> rakudo​: subset G of Str where { .chars > 0 }; multi detect(G)
{}; detect "O"; say "alive"
<p6eval> rakudo e9e7fc​: OUTPUT«alive␤»

@p6rt
Copy link
Author

p6rt commented Oct 7, 2010

From @masak

<tylercurtis> rakudo​: multi detect(Str $foo where { /O/ }) {}; detect "O"
<p6eval> rakudo 377615​: OUTPUT«Null PMC access in isa_pmc() [...]
<tylercurtis> rakudo​: multi detect(Str $foo where /O/) {say 'hi'}; detect "O"
<p6eval> rakudo 377615​: OUTPUT«hi␤»
* masak adds this to the ticket
<masak> tylercurtis++
<masak> rakudo​: subset G of Str where /O/; multi detect(G) {}; detect "O"; say "alive"
<p6eval> rakudo 377615​: OUTPUT«alive␤»
<tylercurtis> rakudo​: multi detect(Str $foo where { m/O/ } ) {say 'hi'}; detect "O"
<p6eval> rakudo 377615​: OUTPUT«hi␤»
<masak> another clue. nice!

@p6rt
Copy link
Author

p6rt commented Oct 7, 2010

@masak - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Aug 7, 2012

From @masak

<masak> r​: sub detect(Str $foo where { /O/ }) {}; detect "O"
<p6eval> rakudo 34e8d4​: OUTPUT«No such method 'match' for invocant of
type 'Any' [...]
<jnthn> Oh...is that a sink context oopsie?
<masak> r​: subset Ostring of Str where { /O/ }; say "O" ~~ Ostring
<p6eval> rakudo 34e8d4​: OUTPUT«No such method 'match' for invocant of
type 'Any' [...]
<masak> seems so.
<jnthn> Not surprising given we don't really do sink context properly
yet.
<jnthn> A curious place for it to fall out though
* masak updates the ticket
<masak> r​: say "O" ~~ { /O/ }
<p6eval> rakudo 34e8d4​: OUTPUT«␤»
<moritz> I guess the problem is that at the point where the regex is
evaluated in boolean context, $_ isn't bound to 'O'

@p6rt
Copy link
Author

p6rt commented Apr 7, 2016

From @diakopter

The original code works now

12​:09 <diakopter> m​: subset Greeting of Str where { /​:i ^oh \s+ \w+ '!'?$/ };
  subset LolGreeting of Str where { .words[1].lc eq 'hai' };
  multi detect(Str) { "not a greeting" }; multi
  detect(Greeting) { "regular greeting" }; multi
  detect(LolGreeting) { "lol-greeting" }; say detect "OH HAI"
12​:09 <camelia> rakudo-moar 61d231​: OUTPUT«lol-greeting␤»

@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