Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

returning Scalar actually returns content #5381

Open
p6rt opened this issue Jun 15, 2016 · 1 comment
Open

returning Scalar actually returns content #5381

p6rt opened this issue Jun 15, 2016 · 1 comment
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 15, 2016

Migrated from rt.perl.org#128409 (status was 'new')

Searchable as RT128409$

@p6rt
Copy link
Author

p6rt commented Jun 15, 2016

From zefram@fysh.org

(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

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant