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

Strange bug in the new given/whereis/whereso construct (perl-5.27.7) #16332

Closed
p5pRT opened this issue Dec 21, 2017 · 6 comments
Closed

Strange bug in the new given/whereis/whereso construct (perl-5.27.7) #16332

p5pRT opened this issue Dec 21, 2017 · 6 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Dec 21, 2017

Migrated from rt.perl.org#132634 (status was 'resolved')

Searchable as RT132634$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 21, 2017

From trizen@protonmail.com

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.

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 21, 2017

From trizen@protonmail.com

bug.pl

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 23, 2017

From zefram@fysh.org

Trizen wrote​:

There seems to be a minor bug in the simplified version of given/when,

Thanks, that's interesting. Turns out it doesn't need any actual
smartmatching, overloading or regexps. It reduces to​:

$ perl5.27.7 -Mexperimental=smartmatch -Mfeature=switch -lwe 'bless({})->append(do { given (3) { my $v = do { whereso(0) { } }; } });'
Can't call method "append" on an undefined value at -e line 1.

and it's not specific to the new version of switch, it also happens on
the old version​:

$ perl5.27.6 -Mexperimental=smartmatch -Mfeature=switch -lwe 'bless({})->append(do { given (3) { my $v = do { when(0) { } }; } });'
Can't call method "append" on an undefined value at -e line 1.

-zefram

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 23, 2017

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 23, 2017

From zefram@fysh.org

Fixed in commit b98da25.

-zefram

@p5pRT p5pRT closed this as completed Dec 28, 2017
@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 28, 2017

@iabyn - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant