Open p6rt opened 8 years ago
See the following results
$ perl6 -e 'sub foo(\a where { *.WHAT === Int } ) { say "Hello"; }; foo(10);'
Constraint type check failed for parameter 'a'
in sub foo at -e line 1
in block \
$ perl6 -e 'sub foo(\a where -> \e { \e.WHAT === Int } ) { say "Hello"; }; foo(10);'
Constraint type check failed for parameter 'a'
in sub foo at -e line 1
in block \
$ perl6 -e 'sub foo(\a where -> \e { e.WHAT === Int } ) { say "Hello"; }; foo(10);' Hello
It seems that "Whatever *" cannot handle sigilless values correctly. I think that the 1st example should return the same result as the 3rd example.
$ perl6 --version This is Rakudo version 2016.08.1-202-g78393dd built on MoarVM version 2016.08-47-g2eedba8 implementing Perl 6.c.
I think this is because .WHAT is a special case. It's not really a method which is what you need to make *.method work. *.WHAT will always return (Whatever) immediately.
There is an odd what of working around this:
perl6 -e 'sub foo(\a where *.&WHAT === Int ) { say "Hello"; }; foo(10); # works
using the &WHAT sub with postfix syntax you get around the special casing.
I'm not sure if .WHAT special casing is considered a bug. I haven't been able to find a pre-existing ticket wrt to it.
On Sat, Sep 24, 2016 at 4:42 PM Itsuki Toyota \perl6\-bugs\-followup@​perl\.org wrote:
# New Ticket Created by Itsuki Toyota # Please include the string: [perl #129346] # in the subject line of all future correspondence about this issue. # \<URL: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=129346 >
See the following results
$ perl6 -e 'sub foo(\a where { *.WHAT === Int } ) { say "Hello"; }; foo(10);' Constraint type check failed for parameter 'a' in sub foo at -e line 1 in block \
at -e line 1 $ perl6 -e 'sub foo(\a where -> \e { \e.WHAT === Int } ) { say "Hello"; }; foo(10);' Constraint type check failed for parameter 'a' in sub foo at -e line 1 in block \
at -e line 1 $ perl6 -e 'sub foo(\a where -> \e { e.WHAT === Int } ) { say "Hello"; }; foo(10);' Hello
It seems that "Whatever *" cannot handle sigilless values correctly. I think that the 1st example should return the same result as the 3rd example.
$ perl6 --version This is Rakudo version 2016.08.1-202-g78393dd built on MoarVM version 2016.08-47-g2eedba8 implementing Perl 6.c.
The RT System itself - Status changed from 'new' to 'open'
On Sat, Sep 24, 2016 at 07:37:52AM +0000, Lloyd Fournier wrote:
I think this is because .WHAT is a special case. It's not really a method which is what you need to make *.method work. *.WHAT will always return (Whatever) immediately.
You're correct that .WHAT is a special case. From S12, "Introspection":
These should all be considered built-in language primitives, not true operators or methods, even if a given implementation happens to implement one or more of them that way.
I suppose it's possible that *.WHAT should generate a WhateverCode object... but I'm a little disinclined to that. A bit later S12 continues:
In general, use of these uppercased accessors in ordinary code should be a red flag that Something Very Strange is going on. (Hence the allcaps.) Most code should use Perl 6's operators that make use of this information implicitly. For instance, instead of
$obj.WHAT === Dog ...
you usually just want:
$obj ~~ Dog
So I'd say this isn't actually a bug.
Pm
On Fri, Sep 23, 2016 at 11:42:20PM -0700, Itsuki Toyota wrote:
: # New Ticket Created by Itsuki Toyota
: # Please include the string: [perl #129346]
: # in the subject line of all future correspondence about this issue.
: # \<URL: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=129346 >
:
:
: See the following results
:
: $ perl6 -e 'sub foo(\a where { *.WHAT === Int } ) { say "Hello"; }; foo(10);'
: Constraint type check failed for parameter 'a'
: in sub foo at -e line 1
: in block \
Even if .WHAT were not special, this wouldn't ever work, because you've got a double-closure there, one from the curlies, and the other from the *. So the outer closure would return the inner closure, which would always evaluate to true.
: $ perl6 -e 'sub foo(\a where -> \e { \e.WHAT === Int } ) { say "Hello"; }; foo(10);'
: Constraint type check failed for parameter 'a'
: in sub foo at -e line 1
: in block \
This will never work because \e.WHAT returns a Capture object, which will never === Int.
: $ perl6 -e 'sub foo(\a where -> \e { e.WHAT === Int } ) { say "Hello"; }; foo(10);' : Hello
That is, in fact, a correct way to write it.
: It seems that "Whatever *" cannot handle sigilless values correctly.
The sigilless variable isn't declared yet, so a.WHAT doesn't work either. But this is another correct way to write it:
$ perl6 -e 'sub foo(\a where { .WHAT === Int } ) { say "Hello"; }; foo(10);' Hello
Larry
Migrated from rt.perl.org#129346 (status was 'open')
Searchable as RT129346$