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
Strange bug in the new given/whereis/whereso construct (perl-5.27.7) #16332
Comments
From trizen@protonmail.comHi, There seems to be a minor bug in the simplified version of given/when, as illustrated in the following code: # ======BEGIN-OF-CODE====== use 5.027007; use experimental qw(smartmatch); package FooObj { use overload '~~' => sub { 1 }, q{""} => sub { 'foo' }; sub new { bless {} } sub append { say "In append: $_[1]"; } } my $obj = FooObj->new; $obj->append( do { given (FooObj->new) { my $t = qr/bar/; my $v = do { # this seems to cause it whereis($t) { 'incorrect' } }; whereis(FooObj->new()) { 'correct' } } } ); # ======END-OF-CODE====== The expected output is "In append: correct". The output under perl-5.27.7 is: Can't call method "append" on an undefined value at bug.pl line 21. For some reason, the $obj variable magically becomes undefined. Output of perlbug -d: Flags: Site configuration information for perl 5.27.7: Configured by swampyx at Thu Dec 21 06:00:57 EET 2017. Summary of my perl5 (revision 5 version 27 subversion 7) configuration: Platform: Locally applied patches: @INC for perl 5.27.7: Environment for perl 5.27.7: Sent with [ProtonMail](https://protonmail.com) Secure Email. |
From zefram@fysh.orgTrizen wrote:
Thanks, that's interesting. Turns out it doesn't need any actual $ perl5.27.7 -Mexperimental=smartmatch -Mfeature=switch -lwe 'bless({})->append(do { given (3) { my $v = do { whereso(0) { } }; } });' and it's not specific to the new version of switch, it also happens on $ perl5.27.6 -Mexperimental=smartmatch -Mfeature=switch -lwe 'bless({})->append(do { given (3) { my $v = do { when(0) { } }; } });' -zefram |
The RT System itself - Status changed from 'new' to 'open' |
From zefram@fysh.orgFixed in commit b98da25. -zefram |
@iabyn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#132634 (status was 'resolved')
Searchable as RT132634$
The text was updated successfully, but these errors were encountered: