Re: What's going on with "given (junction) {when (value)...}"

2021-06-04 Thread Ralph Mellor
On Wed, Jun 2, 2021 at 11:57 AM William Michels  wrote:
>
> Hi Ralph, Both prefix/postfix 'when' look okay on my Rakudo_2020.10 install:

Only postfix in 2021.03:

https://replit.com/@RalphMellor/FooACCEPT-junction#main.raku


Re: What's going on with "given (junction) {when (value)...}"

2021-06-02 Thread William Michels via perl6-users
Hi Ralph, Both prefix/postfix 'when' look okay on my Rakudo_2020.10 install:

user@mbook:~$ raku
Welcome to 퐑퐚퐤퐮퐝퐨™ v2020.10.
Implementing the 퐑퐚퐤퐮™ programming language v6.d.
Built on MoarVM version 2020.10.

To exit type 'exit' or '^D'
> when 3 { say 'prefix when' }
False
> { say 'postfix when' } when 3
()
> $_ := any(4,3);
any(4, 3)
> when 3 { say 'prefix when' }
prefix when
> { say 'postfix when' } when 3
postfix when

> $_ := any(5,4);
any(5, 4)
> when 5 { say 'prefix when' }
prefix when
> { say 'postfix when' } when 5
postfix when

> $*VM
moar (2020.10)
>



HTH, Bill.



On Tue, Jun 1, 2021 at 8:09 AM Ralph Mellor  wrote:
>
> Curiously, it works for postfix `when`:
> ```
> $_ := any(4,3);
> {say 'postfix when'} when 3; # 3
> when 3 { say 'prefix when' }  # (no output)
> ```
>
> --
> love, raiph


Re: What's going on with "given (junction) {when (value)...}"

2021-06-01 Thread Tom Browder
On Tue, Jun 1, 2021 at 11:31 William Michels via perl6-users <
perl6-us...@perl.org> wrote:

> Hi Bruce,
> This is what I see with Rakudo 2020.10 (all code below performs
> delightfully as expected):
>

This whole thread looks like good stuff for some probably missing roast
tests.

-Tom


Re: What's going on with "given (junction) {when (value)...}"

2021-06-01 Thread William Michels via perl6-users
Hi Bruce,

This is what I see with Rakudo 2020.10 (all code below performs
delightfully as expected):

user@mbook:~$ raku
Welcome to 퐑퐚퐤퐮퐝퐨™ v2020.10.
Implementing the 퐑퐚퐤퐮™ programming language v6.d.
Built on MoarVM version 2020.10.

To exit type 'exit' or '^D'
> ? (any(4,3) ~~ 3)
True
>  ? (3 ~~ any(4,3))
True
> given any(4,3) { when 3 {say '3'}; say 'nope'}
3
> given any(4,3) { when 3 {say '3'}; say 'nope'}
3
> given 3 { when any(4,3) {say '3'}; say 'nope'}
3
> given any(4,3) { say .raku }
any(4, 3)

> ? (any(4,3) ~~ 3)
True
> any(4,3) ~~ 3
True
> none(4,3) ~~ 3
False
> one(4,3) ~~ 3
True
> all(4,3) ~~ 3
False

> given any(4,3) { when 3 {say 'TRUE'}; say 'FALSE'; };
TRUE
> given any(4,3) { when 4 {say 'TRUE'}; say 'FALSE'; };
TRUE
> given any(4,3) { when 5 {say 'TRUE'}; say 'FALSE'; };
FALSE
> given any(4,3) { when 3|4|5 {say 'TRUE'}; say 'FALSE'; };
TRUE
> given any(4,3) { when 3||4||5 {say 'TRUE'}; say 'FALSE'; };
TRUE
> given any(4,3) { when 5||4||3 {say 'TRUE'}; say 'FALSE'; };
FALSE
> given any(4,3) { when 5||4|3 {say 'TRUE'}; say 'FALSE'; };
FALSE
> given any(4,3) { when 5|4|3 {say 'TRUE'}; say 'FALSE'; };
TRUE
>

HTH, Bill.


On Mon, May 31, 2021 at 12:45 AM Bruce Gray 
wrote:

>
>
> > On May 30, 2021, at 9:18 PM, yary  wrote:
> >
> > This came up in today's Raku study group (my own golfing-)
> >
> > > ? (any(4,3) ~~ 3)
> > True
> > > ? (3 ~~ any(4,3))
> > True
> > > given any(4,3) { when 3 {say '3'}; say 'nope'}
> > nope
> > > given 3 { when any(4,3) {say '3'}; say 'nope'}
> > 3
> > > given any(4,3) { say .raku }
> > any(4, 3)
> >
> > why does Raku say 'nope' for the example "given any(4,3) { when 3 {say
> '3'}; say 'nope'}"
> >
> > Since this expression is true ? (any(4,3) ~~ 3)
> > I expected the "given 4|3" to also match "when 3"
> >
> > -y
>
> This looks very version dependent, and I would not have expected it to be
> version dependent at all.
>
> Summary of behavior across versions. True means `given any(4,3) { when
> 3...` does match just like its converse, and False means it does not match.
> I have noted possible false negatives; 3 of the docker build have MoarVM
> versions newer than the Rakudo versions. Possible build error?
> False 2020.[1..2] (But suspect, since the VM reported version
> 2020.12)
> True  2020.[5..9]
> False 2020.10 (But suspect, since the VM reported version
> 2020.12)
> True  2020.11
> False 2020.12 through nightly (which was 4 hours ago)
>
> Full detail:
> (All run on JJ's alpine docker images (Thanks JJ!), but on a Windows box
> (hence the double-quotes), because Docker is hosed on my Macbook.)
> C:\Users\bruce>copy con yary_03.bat
> @echo off
> docker run --rm -it jjmerelo/alpine-raku:2020.01 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.02 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.05 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.05.1   -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.06 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.07 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.08 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.08.1   -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.08.2   -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.09 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.10 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.11 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.12 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2021.02 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2021.02.1   -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2021.03 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2021.04 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2021.05 -e "print
> 

Re: What's going on with "given (junction) {when (value)...}"

2021-06-01 Thread Ralph Mellor
Curiously, it works for postfix `when`:
```
$_ := any(4,3);
{say 'postfix when'} when 3; # 3
when 3 { say 'prefix when' }  # (no output)
```

--
love, raiph


Re: What's going on with "given (junction) {when (value)...}"

2021-06-01 Thread Ralph Mellor
On Tue, Jun 1, 2021 at 4:02 AM Larry Wall  wrote:
>
> In my opinion, the most consistent approach is to disallow any
> autothreading of the argument to .ACCEPTS

That sounds like a really appropriate simplification as I write this.

> All those other smartmatches are sugar for .ACCEPTS, and
> should not introduce special cases either.

Sounds great.

> If you want to make use of a junction like that, you must write
>
> when 3 ~~ $_ {...}
>
> or
>
> when 3 == $_ {...}
>
> or so.

Nice.



In the following, ALG = Applying Larry's Guidance.

Do we need an overhaul of .ACCEPTS methods wrt Any / Mu?
https://github.com/rakudo/rakudo/issues/2676
ALG would resolve this?

Range.ACCEPTS gets some things wrong
https://github.com/rakudo/rakudo/issues/1809
ALG would inform problem 1.

For the following ALG *might* be relevant but I haven't
thought things through at all.

Autothreading gone wrong?
https://github.com/rakudo/rakudo/issues/2814

Change in behavior when (starts-with|ends-with|substr-eq|contains)ing a Junction
https://github.com/rakudo/rakudo/issues/2719

using junctions in grep and split is inconsistent
https://github.com/rakudo/rakudo/issues/3893

Junctions don't autothread some methods correctly
https://github.com/Raku/old-issue-tracker/issues/6183



If anyone wants to dig into one or more of those issues,
and decide whether Larry's guidance here is relevant to
them, and link to his guidance if so, that would be cool.

--
love, raiph


Re: What's going on with "given (junction) {when (value)...}"

2021-05-31 Thread Larry Wall
In my opinion, the most consistent approach is to disallow any
autothreading of the argument to .ACCEPTS, such that 3.ACCEPTS(any(3,4))
simply returns False.  I suspect the only thing that returns True for
that sort of argument is Junction.ACCEPTS(any(3,4)) and such.  And we
can't autothread that, or it would falsely return False.  So I think
treating the unrecognized $other as a raw Mu returning False (rather than
a threadable Any returning a junction) is the most consistent, if not
always in line with everyone's expections, which are not consistent.  :)

All those other smartmatches are sugar for .ACCEPTS, and should not introduce
special cases either.  If you want to make use of a junction like that,
you must write

when 3 ~~ $_ {...}

or

when 3 == $_ {...}

or so.  This is enough to tell the optimizer not to make a jump table.
(Though conceivably spesh could still do that for cases where $_ is
provably an integer, I guess.)

Larry

On Mon, May 31, 2021 at 08:09:05PM -0400, yary wrote:
: Thanks for the explanation, I think the docs (and Roast) also can be more
: explicit on the difference between
: $left ~~ $right
: and
: $right.ACCEPTS($left)
: and
: given ($left) { when $right { ... } }
: and
: ... when $right;
: 
: ralph-if you are reading this, last week you went into detail about the
: tradeoffs of special-casing Junction handling, how do you view these cases
: where the topic "$left" is a Junction?
: 
: Larry the second thing I did on reading your answer (first being re-reading
: and thinking about it) was to try the underlying ACCEPTS- do you think
: ACCEPTS should return False here, or is it `~~` and `when` that should
: coerce Junctions into something that fails against the right side?
: 
: > 3.ACCEPTS(any(3,4))
: any(True, False)
: 
: > ? (3.ACCEPTS(any(3,4)))
: True
: 
: -y
: 
: 
: On Mon, May 31, 2021 at 6:38 PM Larry Wall  wrote:
: 
: > On Sun, May 30, 2021 at 10:18:13PM -0400, yary wrote:
: > : This came up in today's Raku study group (my own golfing-)
: > :
: > : > ? (any(4,3) ~~ 3)
: > : True
: > : > ? (3 ~~ any(4,3))
: > : True
: > : > given any(4,3) { when 3 {say '3'}; say 'nope'}
: > : nope
: > : > given 3 { when any(4,3) {say '3'}; say 'nope'}
: > : 3
: > : > given any(4,3) { say .raku }
: > : any(4, 3)
: > :
: > : why does Raku say 'nope' for the example *"**given any(4,3) { when 3 {say
: > : '3'}; say 'nope'}*"
: > :
: > : Since this expression is true *? (any(4,3) ~~ 3)*
: > : I expected the "*given 4|3*" to also match "*when 3*"
: >
: > I think both of these should be returning False.  In general, the left
: > side of ~~ should
: > not be auto-threading, or we revert to the suboptimal Perl semantics of
: > smartmatching.
: > The reason we broke the symmetry of smartmatch is so that we can optimize
: > based on
: > the type of the right-hand argument, and allowing auto-threading of the
: > other argument
: > prevents that.  Note that in the switch structure above, "when 3" is
: > supposed to be
: > optimizable to a jump table, but how do you calculate a jump from a
: > junction?  So we
: > biased smartmatching in the direction of coercion-first semantics rather
: > early on
: > (though, alas, not early enough to prevent Perl adoption of the earlier
: > design).
: >
: > In any case, the documentation says ~~ is defined underlyingly by
: > .ACCEPTS, and
: > for a Numeric pattern, that says:
: >
: > multi method ACCEPTS(Numeric:D: $other)
: >
: > Returns True if $other can be coerced to Numeric and is numerically
: > equal to the invocant
: > (or both evaluate to NaN).
: >
: > And I'd be awfully surprised if any(4,3) can be coerced to Numeric in any
: > meaningful way...
: >
: > Perhaps this should be documented as a trap for people coming from Perl,
: > if it isn't already.
: >
: > Larry
: >


Re: What's going on with "given (junction) {when (value)...}"

2021-05-31 Thread yary
Thanks for the explanation, I think the docs (and Roast) also can be more
explicit on the difference between
$left ~~ $right
and
$right.ACCEPTS($left)
and
given ($left) { when $right { ... } }
and
... when $right;

ralph-if you are reading this, last week you went into detail about the
tradeoffs of special-casing Junction handling, how do you view these cases
where the topic "$left" is a Junction?

Larry the second thing I did on reading your answer (first being re-reading
and thinking about it) was to try the underlying ACCEPTS- do you think
ACCEPTS should return False here, or is it `~~` and `when` that should
coerce Junctions into something that fails against the right side?

> 3.ACCEPTS(any(3,4))
any(True, False)

> ? (3.ACCEPTS(any(3,4)))
True

-y


On Mon, May 31, 2021 at 6:38 PM Larry Wall  wrote:

> On Sun, May 30, 2021 at 10:18:13PM -0400, yary wrote:
> : This came up in today's Raku study group (my own golfing-)
> :
> : > ? (any(4,3) ~~ 3)
> : True
> : > ? (3 ~~ any(4,3))
> : True
> : > given any(4,3) { when 3 {say '3'}; say 'nope'}
> : nope
> : > given 3 { when any(4,3) {say '3'}; say 'nope'}
> : 3
> : > given any(4,3) { say .raku }
> : any(4, 3)
> :
> : why does Raku say 'nope' for the example *"**given any(4,3) { when 3 {say
> : '3'}; say 'nope'}*"
> :
> : Since this expression is true *? (any(4,3) ~~ 3)*
> : I expected the "*given 4|3*" to also match "*when 3*"
>
> I think both of these should be returning False.  In general, the left
> side of ~~ should
> not be auto-threading, or we revert to the suboptimal Perl semantics of
> smartmatching.
> The reason we broke the symmetry of smartmatch is so that we can optimize
> based on
> the type of the right-hand argument, and allowing auto-threading of the
> other argument
> prevents that.  Note that in the switch structure above, "when 3" is
> supposed to be
> optimizable to a jump table, but how do you calculate a jump from a
> junction?  So we
> biased smartmatching in the direction of coercion-first semantics rather
> early on
> (though, alas, not early enough to prevent Perl adoption of the earlier
> design).
>
> In any case, the documentation says ~~ is defined underlyingly by
> .ACCEPTS, and
> for a Numeric pattern, that says:
>
> multi method ACCEPTS(Numeric:D: $other)
>
> Returns True if $other can be coerced to Numeric and is numerically
> equal to the invocant
> (or both evaluate to NaN).
>
> And I'd be awfully surprised if any(4,3) can be coerced to Numeric in any
> meaningful way...
>
> Perhaps this should be documented as a trap for people coming from Perl,
> if it isn't already.
>
> Larry
>


Re: What's going on with "given (junction) {when (value)...}"

2021-05-31 Thread Larry Wall
On Sun, May 30, 2021 at 10:18:13PM -0400, yary wrote:
: This came up in today's Raku study group (my own golfing-)
: 
: > ? (any(4,3) ~~ 3)
: True
: > ? (3 ~~ any(4,3))
: True
: > given any(4,3) { when 3 {say '3'}; say 'nope'}
: nope
: > given 3 { when any(4,3) {say '3'}; say 'nope'}
: 3
: > given any(4,3) { say .raku }
: any(4, 3)
: 
: why does Raku say 'nope' for the example *"**given any(4,3) { when 3 {say
: '3'}; say 'nope'}*"
: 
: Since this expression is true *? (any(4,3) ~~ 3)*
: I expected the "*given 4|3*" to also match "*when 3*"

I think both of these should be returning False.  In general, the left side of 
~~ should
not be auto-threading, or we revert to the suboptimal Perl semantics of 
smartmatching.
The reason we broke the symmetry of smartmatch is so that we can optimize based 
on
the type of the right-hand argument, and allowing auto-threading of the other 
argument
prevents that.  Note that in the switch structure above, "when 3" is supposed 
to be
optimizable to a jump table, but how do you calculate a jump from a junction?  
So we
biased smartmatching in the direction of coercion-first semantics rather early 
on
(though, alas, not early enough to prevent Perl adoption of the earlier design).

In any case, the documentation says ~~ is defined underlyingly by .ACCEPTS, and
for a Numeric pattern, that says:

multi method ACCEPTS(Numeric:D: $other)

Returns True if $other can be coerced to Numeric and is numerically equal 
to the invocant
(or both evaluate to NaN).

And I'd be awfully surprised if any(4,3) can be coerced to Numeric in any 
meaningful way...

Perhaps this should be documented as a trap for people coming from Perl, if it 
isn't already.

Larry


Re: What's going on with "given (junction) {when (value)...}"

2021-05-31 Thread yary
Nice checking! I opened https://github.com/rakudo/rakudo/issues/4386
-y


On Mon, May 31, 2021 at 3:45 AM Bruce Gray 
wrote:

>
>
> > On May 30, 2021, at 9:18 PM, yary  wrote:
> >
> > This came up in today's Raku study group (my own golfing-)
> >
> > > ? (any(4,3) ~~ 3)
> > True
> > > ? (3 ~~ any(4,3))
> > True
> > > given any(4,3) { when 3 {say '3'}; say 'nope'}
> > nope
> > > given 3 { when any(4,3) {say '3'}; say 'nope'}
> > 3
> > > given any(4,3) { say .raku }
> > any(4, 3)
> >
> > why does Raku say 'nope' for the example "given any(4,3) { when 3 {say
> '3'}; say 'nope'}"
> >
> > Since this expression is true ? (any(4,3) ~~ 3)
> > I expected the "given 4|3" to also match "when 3"
> >
> > -y
>
> This looks very version dependent, and I would not have expected it to be
> version dependent at all.
>
> Summary of behavior across versions. True means `given any(4,3) { when
> 3...` does match just like its converse, and False means it does not match.
> I have noted possible false negatives; 3 of the docker build have MoarVM
> versions newer than the Rakudo versions. Possible build error?
> False 2020.[1..2] (But suspect, since the VM reported version
> 2020.12)
> True  2020.[5..9]
> False 2020.10 (But suspect, since the VM reported version
> 2020.12)
> True  2020.11
> False 2020.12 through nightly (which was 4 hours ago)
>
> Full detail:
> (All run on JJ's alpine docker images (Thanks JJ!), but on a Windows box
> (hence the double-quotes), because Docker is hosed on my Macbook.)
> C:\Users\bruce>copy con yary_03.bat
> @echo off
> docker run --rm -it jjmerelo/alpine-raku:2020.01 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.02 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.05 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.05.1   -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.06 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.07 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.08 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.08.1   -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.08.2   -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.09 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.10 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.11 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2020.12 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2021.02 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2021.02.1   -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2021.03 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2021.04 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:2021.05 -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:latest  -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> docker run --rm -it jjmerelo/alpine-raku:nightly -e "print
> $*VM.version; given any(4,3) { when 3 {say True}; say False; };"
> ^Z
> 1 file(s) copied.
>
> C:\Users\bruce>yary_03.bat
> 2020.12False
> 2020.12False
> 2020.05True
> 2020.05True
> 2020.06True
> 2020.07True
> 2020.07.16.g.03.d.3.e.43.faTrue
> 2020.08True
> 2020.08True
> 2020.09True
> 2020.12False
> 2020.11True
> 2020.12False
> 2021.02False
> 2021.02False
> 2021.03False
> 2021.04False
> 2021.05False
> 2021.05False
> 2021.05False
>
>
> In https://github.com/MoarVM/MoarVM/blob/master/docs/ChangeLog , I see
> nothing in 2020.11 that looks like the culprit.
> In https://github.com/rakudo/rakudo/blob/master/docs/ChangeLog , I see
> nothing in 2020.11 that looks like the culprit, but that big change in
> coersion ("new coertion semantics”) was big enough to make that a good
> candidate for proper bisecting.
> (but 

Re: What's going on with "given (junction) {when (value)...}"

2021-05-31 Thread Bruce Gray



> On May 30, 2021, at 9:18 PM, yary  wrote:
> 
> This came up in today's Raku study group (my own golfing-)
> 
> > ? (any(4,3) ~~ 3)
> True
> > ? (3 ~~ any(4,3))
> True
> > given any(4,3) { when 3 {say '3'}; say 'nope'}
> nope
> > given 3 { when any(4,3) {say '3'}; say 'nope'}
> 3
> > given any(4,3) { say .raku }
> any(4, 3)
> 
> why does Raku say 'nope' for the example "given any(4,3) { when 3 {say '3'}; 
> say 'nope'}"
> 
> Since this expression is true ? (any(4,3) ~~ 3)
> I expected the "given 4|3" to also match "when 3"
>  
> -y

This looks very version dependent, and I would not have expected it to be 
version dependent at all.

Summary of behavior across versions. True means `given any(4,3) { when 3...` 
does match just like its converse, and False means it does not match.
I have noted possible false negatives; 3 of the docker build have MoarVM 
versions newer than the Rakudo versions. Possible build error?
False 2020.[1..2] (But suspect, since the VM reported version 2020.12)
True  2020.[5..9]
False 2020.10 (But suspect, since the VM reported version 2020.12)
True  2020.11
False 2020.12 through nightly (which was 4 hours ago)

Full detail:
(All run on JJ's alpine docker images (Thanks JJ!), but on a Windows box (hence 
the double-quotes), because Docker is hosed on my Macbook.)
C:\Users\bruce>copy con yary_03.bat
@echo off
docker run --rm -it jjmerelo/alpine-raku:2020.01 -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2020.02 -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2020.05 -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2020.05.1   -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2020.06 -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2020.07 -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2020.08 -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2020.08.1   -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2020.08.2   -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2020.09 -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2020.10 -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2020.11 -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2020.12 -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2021.02 -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2021.02.1   -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2021.03 -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2021.04 -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:2021.05 -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:latest  -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
docker run --rm -it jjmerelo/alpine-raku:nightly -e "print $*VM.version; 
given any(4,3) { when 3 {say True}; say False; };"
^Z
1 file(s) copied.

C:\Users\bruce>yary_03.bat
2020.12False
2020.12False
2020.05True
2020.05True
2020.06True
2020.07True
2020.07.16.g.03.d.3.e.43.faTrue
2020.08True
2020.08True
2020.09True
2020.12False
2020.11True
2020.12False
2021.02False
2021.02False
2021.03False
2021.04False
2021.05False
2021.05False
2021.05False


In https://github.com/MoarVM/MoarVM/blob/master/docs/ChangeLog , I see nothing 
in 2020.11 that looks like the culprit.
In https://github.com/rakudo/rakudo/blob/master/docs/ChangeLog , I see nothing 
in 2020.11 that looks like the culprit, but that big change in coersion ("new 
coertion semantics”) was big enough to make that a good candidate for proper 
bisecting.
(but not by me; I am out of time for this week)

— 
Hope this helps,
Bruce Gray (Util of PerlMonks)