Skip Menu |
Report information
Id: 118865
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: jimmy.zhuo [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: Parameter '' requires an instance, LTA error
Date: Thu, 11 Jul 2013 21:26:08 +0800
To: <rakudobug [...] perl.org>
From: "Jimmy Zhuo" <jimmy.zhuo [...] gmail.com>
Download (untitled) / with headers
text/plain 667b
Show quoted text
JimmyZ> r: sub f(Int $x where $x > 0) { say "yup" }; my Int $a; f($a);
Show quoted text
Camellia> rakudo b19f72: OUTPUT«Parameter '' requires an instance, but a type object was passed␤ in method Bridge at src/gen/CORE.setting:3562␤ in sub infix:<>> at src/gen/CORE.setting:3490␤ in sub infix:<>> at src/gen/CORE.setting:3340␤ in sub f at /tmp/RSujJD9_FI:1␤ in block at /tmp/RSujJ…
The above is missing '$x'. Show quoted text
Timotimo> r: sub f(Int:D $x) { say "yup" }; my Int $a; f($a);
Show quoted text
camellia> rakudo b19f72: OUTPUT«Parameter '$x' requires an instance, but a type object was passed␤ in sub f at /tmp/9PHIMfVEzS:1␤ in block at /tmp/9PHIMfVEzS:1␤␤»
--- Jimmy Zhuo
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 670b
The error message has changed slightly and now states that "Invocant requires an instance". $ perl6 -e 'sub f(Int $x where $x > 0) { say "yup" }; my Int $a; f($a);' Invocant requires an instance, but a type object was passed in method Bridge at src/gen/m-CORE.setting:5578 in sub infix:<>> at src/gen/m-CORE.setting:5505 in method ACCEPTS at src/gen/m-CORE.setting:3844 in sub f at -e:1 in block <unit> at -e:1 Formerly the message said "Parameter '' requires an instance" (and the whole bug report is about the missing parameter name $x within this message). IMHO the current error message is good -- even without speaking about $x. So, is this closeable?
From: Jonathan Scott Duff <duff [...] pobox.com>
CC: perl6-compiler <perl6-compiler [...] perl.org>
Date: Thu, 12 Mar 2015 08:19:17 -0500
To: bugs-comment [...] bugs6.perl.org
Subject: Re: [perl #118865] Parameter '' requires an instance, LTA error
Download (untitled) / with headers
text/plain 946b
IMHO, the message is actually slightly worse.   Now it's talking about an invocant when there are no classes or methods involved!

-Scott

On Wed, Mar 11, 2015 at 1:26 PM, Christian Bartolomaeus via RT <bugs-comment@bugs6.perl.org> wrote:
Show quoted text
The error message has changed slightly and now states that "Invocant requires an instance".

$ perl6 -e 'sub f(Int $x where $x > 0) { say "yup" }; my Int $a; f($a);'
Invocant requires an instance, but a type object was passed
  in method Bridge at src/gen/m-CORE.setting:5578
  in sub infix:<>> at src/gen/m-CORE.setting:5505
  in method ACCEPTS at src/gen/m-CORE.setting:3844
  in sub f at -e:1
  in block <unit> at -e:1

Formerly the message said "Parameter '' requires an instance" (and the whole bug report is about the missing parameter name $x within this message).

IMHO the current error message is good -- even without speaking about $x.

So, is this closeable?

From: bri <bri [...] abrij.org>
To: perl6-bugs-followup [...] perl.org
Subject: [perl #118865]
Date: Sat, 8 Aug 2015 23:37:32 -0400
Download (untitled) / with headers
text/plain 1.7k
FWIW there are two layers to this ticket: failure on operators, and faiures within where clauses. The error is due to a failure during evaluation the where clause and does not say '$x' for the same reason this does not: $ perl6 -e 'my Int $x; my $f = $x > 0;' Invocant requires an instance of type Int, but a type object was passed. Did you forget a .new? ... The "invocant" is because the '>' operator is finding its candidate through class methods. That cannot be improved at the runtime bind site as variable names have been optimized away. Rejecting :Us earlier in the bridgework might allow the error to occur earlier where more information is still available, and that would give an eject marker at the right character in the code: $ perl6 -e 'sub b (Str $a) { }; sub f(Int $x where { b(3) } ) { say "yup" }; my Int $a; f($a);' ===SORRY!=== Error while compiling -e Calling b(int) will never work with declared signature (Str $a) at -e:1 ------> ub b (Str $a) { }; sub f(Int $x where { ⏏b(3) } ) { say "yup" }; my Int $a; f($a) ...but it has to be done with care for optimizability and could be messy what with all the multi candidates involved. As a sidenote, it is not very idiomatic to repeat the parameter name in the parameter's own where clause, and it would normally be written: sub f(Int $x where * > 0) ...and FWIW using Int:D would yield: $ perl6 -e 'sub f(Int:D $x where * > 0) { say "yup" }; my Int $a; f($a);' Parameter '$x' requires an instance of type Int, but a type object was passed. Did you forget a .new? But whether failures that occur during a runtime constraint check should emit a worry to identify the offending where clause is a good question. Perhaps where clauses could have an extra implicit CATCH... worry... rethrow, since they tend to be called so close to the binder.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org