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

Owner: Nobody
Requestors: zefram [at]

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

To: rakudobug [...]
From: Zefram <zefram [...]>
Subject: [BUG] returning Scalar actually returns content
Date: Wed, 15 Jun 2016 10:36:01 +0100
Download (untitled) / with headers
text/plain 462b
Show quoted text
> (sub () { my $a = 22; my $b = $a.VAR; $b.WHAT.say; $b })().WHAT.say
(Scalar) (Int) $b is a Scalar, and the subroutine attempts to return it. The caller doesn't receive it; instead it receives the Int that was contained in the Scalar. This happens specifically when the sub has the Scalar in a variable and the return expression is a reference to that variable. If the return expression is "$a.VAR", then the caller receives the Scalar as expected. -zefram

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

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