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
defined should not propagate ref context #11587
Comments
From @cpansproutI was trying to call a subroutine with the current @_, and check its return value for definition. So I changed defined &foo which obviously doesn’t work, to defined do { &foo } That didn’t help. In playing around with it, I’ve found it actually to be interestingly buggy: $ perl -le'sub foo{warn called} print defined(scalar(42,&foo))' Didn’t expect that, did you? This is even better: $ perl -le'sub foo{} defined do{();&foo}' I get those same results with every version I’ve tried from 5.6.2 to 5.15.1. I don’t think defined should be propagating ref context that far. In other words, S_doref in op.c should be circumspect about calling itself when the type is OP_DEFINED. Likewise, I don’t think defined($false ? $scalar : @array) should be doing defined (@array), but the equivalent of defined(my $tmp = @array) (without the $tmp). defined(scalar @foo) also is a bit surprising. It does the same thing as defined(@foo). From the point of view of the implementation, that makes some sense. But scalar() is documented as a function, not a flag on an operator, so I would expect scalar @foo to return the length, and defined to return true because the length is defined. Flags: Site configuration information for perl 5.15.1: Configured by sprout at Fri Jul 22 19:53:36 PDT 2011. Summary of my perl5 (revision 5 version 15 subversion 1) configuration: Locally applied patches: @INC for perl 5.15.1: Environment for perl 5.15.1: |
From @cpansproutFixed in 518618a. |
@cpansprout - Status changed from 'new' to 'resolved' |
Migrated from rt.perl.org#97466 (status was 'resolved')
Searchable as RT97466$
The text was updated successfully, but these errors were encountered: