Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

Issue with one and none Junctions when passed as parameter #6667

Closed p6rt closed 6 years ago

p6rt commented 6 years ago

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

Searchable as RT132780$

p6rt commented 6 years ago

From shinobi.cl@gmail.com

I need the junction to be applied inside the regex, not at time of parameter binding, so i use the type Mu.

`

my Regex @​rxs = (rx/3/, rx/2/); my @​L = (1 .. 23); sub search(Mu $r where Regex) { grep $r, :v, @​L }; say search( any(@​rxs) ); (2 3 12 13 20 21 22 23)

my Regex @​rxs = (rx/3/, rx/2/); my @​L = (1 .. 23); sub search(Mu $r where Regex) { grep $r, :v, @​L }; say search( all(@​rxs) ); (23)

my Regex @​rxs = (rx/3/, rx/2/); my @​L = (1 .. 23); sub search(Mu $r where Regex) { grep $r, :v, @​L }; say search( one(@​rxs) ); Constraint type check failed in binding to parameter '$r'; expected anonymous constraint to be met but got Junction (one(rx/3/, rx/2/))   in sub search at \ line 1   in block \ at \ line 1

my Regex @​rxs = (rx/3/, rx/2/); my @​L = (1 .. 23); sub search(Mu $r where Regex) { grep $r, :v, @​L }; say search( none(@​rxs) ); Died with X​::TypeCheck​::Binding​::Parameter   in sub search at \ line 1   in block \ at \ line 1

`

Now, removing Mu, just because :). When used with none, a strange warning message appears

my Regex @​rxs = (rx/3/, rx/2/); my @​L = (1 .. 23); sub search($r where Regex) { grep $r, :v, @​L }; say search( any(@​rxs) ); (3 13 23) (2 12 20 21 22 23) my Regex @​rxs = (rx/3/, rx/2/); my @​L = (1 .. 23); sub search($r where Regex) { grep $r, :v, @​L }; say search( all(@​rxs) ); (3 13 23) (2 12 20 21 22 23) my Regex @​rxs = (rx/3/, rx/2/); my @​L = (1 .. 23); sub search($r where Regex) { grep $r, :v, @​L }; say search( one(@​rxs) ); (3 13 23) (2 12 20 21 22 23) my Regex @​rxs = (rx/3/, rx/2/); my @​L = (1 .. 23); sub search($r where Regex) { grep $r, :v, @​L }; say search( none(@​rxs) ); (3 13 23) (2 12 20 21 22 23) No such method 'handled' for invocant of type 'Bool'

-- -shinobi.cl-

p6rt commented 6 years ago

From @zoffixznet

Thank you for the report.

On Sun, 28 Jan 2018 21​:40​:35 -0800, shinobi.cl@​gmail.com wrote​:

I need the junction to be applied inside the regex, not at time of parameter binding, so i use the type Mu.

This part I explained last night on IRC​: https://irclog.perlgeek.de/perl6/2018-01-29#i_15750058

It works as expected, with Junction type affecting the `where` check. You can achieve what you want by threading through a block inside a where​: https://irclog.perlgeek.de/perl6/2018-01-29#i_15750022

Now, removing Mu, just because :). When used with none, a strange warning message appears

my Regex @​rxs = (rx/3/, rx/2/); my @​L = (1 .. 23); sub search($r where Regex) { grep $r, :v, @​L }; say search( none(@​rxs) ); (3 13 23) (2 12 20 21 22 23) No such method 'handled' for invocant of type 'Bool'

This portion was a REPL bug and is now fixed​:

Fix​: https://github.com/rakudo/rakudo/commit/2c36ab2ef94b3f9 Test​: https://github.com/rakudo/rakudo/commit/2c36ab2ef94b3f9

Possibly more of such bugs exist in our codebase. I opened another ticket for codebase review​: https://github.com/rakudo/rakudo/issues/1456

p6rt commented 6 years ago

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

p6rt commented 6 years ago

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