Skip Menu |
Report information
Id: 126462
Status: new
Priority: 0/
Queue: perl6

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

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



To: rakudobug [...] perl.org
From: mt1957 <mt1957 [...] gmail.com>
Subject: Bug returning objects directly from called methods using some form of named arguments
Date: Mon, 26 Oct 2015 22:25:19 +0100
Download (untitled) / with headers
text/plain 1.2k
Two samples of code for which the problem is closely related The first problem; return MongoDB::Cursor.new( collection => self, OP_REPLY => $OP_REPLY, criteria => %@criteria ); Generates the error; 'Default constructor for 'MongoDB::Cursor' only takes named arguments' The second problem; return self.find-and-modify( $criteria, $projection, :$remove, :$update, :$sort, :$new, :$upsert ); Generates: 'Too many positionals passed; expected 1 to 3 arguments but got 8' The different errors are caused by the order of testing steps done by perl6. The named arguments are converted to or seen as positionals in some way when it is used together with the return statement. To make it work I had to resort to the following. my $c = MongoDB::Cursor.new( collection => self, OP_REPLY => $OP_REPLY, criteria => %@criteria ); return $c; and for the second the same way my $h = self.find-and-modify( $criteria, $projection, :$remove, :$update, :$sort, :$new, :$upsert ); return $h; perl6 version 2015.09-346-g0251b52 built on MoarVM version 2015.09-74-gedc44b5


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