# New Ticket Created by Trizen # Please include the string: [perl #132634] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=132634 > Hi, 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: category=core severity=low --- 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: osname=linux osvers=4.14.7-1-arch archname=x86_64-linux-thread-multi uname='linux arch 4.14.7-1-arch #1 smp preempt sun dec 17 19:13:39 utc 2017 x86_64 gnulinux ' config_args='-de -Dprefix=/home/swampyx/perl5/perlbrew/perls/perl-5.27.7 -Doptimize=-march=native -Ofast -pipe -Dman1dir=none -Dman3dir=none -Dusethreads -Dusemultiplicity -Dusedevel -Aeval:scriptdir=/home/swampyx/perl5/perlbrew/perls/perl-5.27.7/bin' hint=recommended useposix=true d_sigaction=define useithreads=define usemultiplicity=define use64bitint=define use64bitall=define uselongdouble=undef usemymalloc=n default_inc_excludes_dot=define bincompat5005=undef Compiler: cc='cc' ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2' optimize='-march=native -Ofast -pipe' cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include' ccversion='' gccversion='7.2.1 20171128' gccosandvers='' intsize=4 longsize=8 ptrsize=8 doublesize=8 byteorder=12345678 doublekind=3 d_longlong=define longlongsize=8 d_longdbl=define longdblsize=16 longdblkind=3 ivtype='long' ivsize=8 nvtype='double' nvsize=8 Off_t='off_t' lseeksize=8 alignbytes=8 prototype=define Linker and Libraries: ld='cc' ldflags =' -fstack-protector-strong -L/usr/local/lib' libpth=/usr/local/lib /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/include-fixed /usr/lib /lib/../lib /usr/lib/../lib /lib /lib64 /usr/lib64 libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc libc=libc-2.26.so so=so useshrplib=false libperl=libperl.a gnulibc_version='2.26' Dynamic Linking: dlsrc=dl_dlopen.xs dlext=so d_dlsymun=undef ccdlflags='-Wl,-E' cccdlflags='-fPIC' lddlflags='-shared -march=native -Ofast -pipe -L/usr/local/lib -fstack-protector-strong' Locally applied patches: Devel::PatchPerl 1.48 --- @INC for perl 5.27.7: /home/swampyx/perl5/perlbrew/perls/perl-5.27.7/lib/site_perl/5.27.7/x86_64-linux-thread-multi /home/swampyx/perl5/perlbrew/perls/perl-5.27.7/lib/site_perl/5.27.7 /home/swampyx/perl5/perlbrew/perls/perl-5.27.7/lib/5.27.7/x86_64-linux-thread-multi /home/swampyx/perl5/perlbrew/perls/perl-5.27.7/lib/5.27.7 --- Environment for perl 5.27.7: HOME=/home/swampyx LANG=en_US.UTF-8 LANGUAGE (unset) LC_CTYPE=en_US.UTF-8 LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/swampyx/perl5/perlbrew/bin:/home/swampyx/perl5/perlbrew/perls/perl-5.27.7/bin:/usr/lib/ccache/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/share/perl6/vendor/bin PERL5LIB= PERLBREW_LIB= PERLBREW_MANPATH=/home/swampyx/perl5/perlbrew/perls/perl-5.27.7/man PERLBREW_PATH=/home/swampyx/perl5/perlbrew/bin:/home/swampyx/perl5/perlbrew/perls/perl-5.27.7/bin PERLBREW_PERL=perl-5.27.7 PERLBREW_ROOT=/home/swampyx/perl5/perlbrew PERLBREW_SKIP_INIT=1 PERLBREW_VERSION=0.82 PERL_BADLANG (unset) PERL_LOCAL_LIB_ROOT= SHELL=/usr/bin/zsh Sent with [ProtonMail](https://protonmail.com) Secure Email.Thread Next