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
Return with a bareword compiles under strict #21716
Comments
This has to do with the way list ops are parsed. One of the possible productions for a listop in the grammar is:
where LSTOP is the op (OP_RETURN, OP_PRINT etc),
It also parses other code like:
which parses, but is then rejected in the op's check function (which is Perl_ck_fun, used by many other ops). I'll look at a fix. |
Since return isn't actually a function, I didn't think the "function" part of the original message applied. Fixes Perl#21716
Since return isn't actually a function, I didn't think the "function" part of the original message applied. Fixes Perl#21716
Since return isn't actually a function, I didn't think the "function" part of the original message applied. Fixes #21716
Why not? Worth mentioning that it's also because |
Because it's documented not to do so:
The other operators that take an indirect object are output operators like print that treat the object as a file handle, what do you expect
I'm not sure what you mean here, at first I thought you might mean returning by running off the end of a function, but that's unrelated to the return operator. |
Ah no, I meant if we omit Thank you very much for the commits 👍🏻 |
I'm not confused, I understand implicit return may not work the same as explicit. I just did not think return should mask errors like that. But I'd rather not to depend on implicit behavior in case of returning. Thanks for the fix, Tony. |
Description
return sum map { ... } @list
seems to compile OK under strict without the import ofList::Util::sum
and returns a filehandle and a mapped list.Steps to Reproduce
This program shows the behavior:
The actual error occurs only after you remove
return
. Removingmap
causes it to report a warning, but it still runs.Expected behavior
I expected to get an error about invalid bareword under strict mode, same as without
return
.Perl configuration
Behavior is consistent on both perl 5.10.1 and 5.38.2.
The text was updated successfully, but these errors were encountered: