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

Double non-numeric warning in range #13268

Open
p5pRT opened this issue Sep 15, 2013 · 8 comments
Open

Double non-numeric warning in range #13268

p5pRT opened this issue Sep 15, 2013 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 15, 2013

Migrated from rt.perl.org#119819 (status was 'open')

Searchable as RT119819$

@p5pRT
Copy link
Author

p5pRT commented Sep 15, 2013

From @cpansprout

$ ./perl -Ilib -we '()=*foo..3'
Name "main​::foo" used only once​: possible typo at -e line 1.
Argument "*main​::foo" isn't numeric in range (or flop) at -e line 1.
Argument "*main​::foo" isn't numeric in range (or flop) at -e line 1.


Flags​:
  category=core
  severity=low


Site configuration information for perl 5.19.4​:

Configured by sprout at Mon Sep 9 00​:16​:24 PDT 2013.

Summary of my perl5 (revision 5 version 19 subversion 4) configuration​:
  Commit id​: d47819ff6f55bfaa4b7eddc66c6db7d7dfdec11c
  Platform​:
  osname=darwin, osvers=12.2.0, archname=darwin-2level
  uname='darwin pint.local 12.2.0 darwin kernel version 12.2.0​: sat aug 25 00​:48​:52 pdt 2012; root​:xnu-2050.18.24~1release_x86_64 x86_64 '
  config_args='-de -Dcc=gcc -Dusedevel -Doptimize=-ggdb3 -Aoptimize=-O0 -DDEBUGGING'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=define, use64bitall=define, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='gcc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
  optimize='-ggdb3 -O0',
  cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
  ccversion='', gccversion='4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)', gccosandvers=''
  intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib'
  libpth=/usr/local/lib /usr/lib
  libs=-ldbm -ldl -lm -lutil -lc
  perllibs=-ldl -lm -lutil -lc
  libc=, so=dylib, useshrplib=false, libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector'


@​INC for perl 5.19.4​:
  lib
  /usr/local/lib/perl5/site_perl/5.19.4/darwin-2level
  /usr/local/lib/perl5/site_perl/5.19.4
  /usr/local/lib/perl5/5.19.4/darwin-2level
  /usr/local/lib/perl5/5.19.4
  /usr/local/lib/perl5/site_perl
  .


Environment for perl 5.19.4​:
  DYLD_LIBRARY_PATH (unset)
  HOME=/Users/sprout
  LANG=en_US.UTF-8
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/usr/bin​:/bin​:/usr/sbin​:/sbin​:/usr/local/bin​:/usr/local/bin
  PERL_BADLANG (unset)
  SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Dec 4, 2014

From @jkeenan

On Sun Sep 15 13​:40​:08 2013, sprout wrote​:

$ ./perl -Ilib -we '()=*foo..3'
Name "main​::foo" used only once​: possible typo at -e line 1.
Argument "*main​::foo" isn't numeric in range (or flop) at -e line 1.
Argument "*main​::foo" isn't numeric in range (or flop) at -e line 1.

As the patch attached shows, this problem seems to occur only on the command-line -- not in a program in a file.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Dec 4, 2014

From @jkeenan

119819-do-not-apply.diff
diff --git a/t/op/range.t b/t/op/range.t
index 7809882..c0eef4d 100644
--- a/t/op/range.t
+++ b/t/op/range.t
@@ -9,7 +9,7 @@ require './test.pl';
 
 use Config;
 
-plan (141);
+plan (142);
 
 is(join(':',1..5), '1:2:3:4:5');
 
@@ -403,4 +403,17 @@ is( ( join ' ', map { join '', map ++$_, 'a'..'d'      } 1..2 ), 'bcde bcde',
 $s = ''; for (1..2) { for ('a'..'d') { $s .= ++$_ } $s.=' ' if $_==1; }
 is( $s, 'bcde bcde','modifiable alpha counting loop counter' );
 
+{
+    # test non-numeric warning in range (RT #119819)
+    my $msg = '';
+    local $SIG{__WARN__} = sub { $msg = $_[0] };
+    use warnings;
+    () = *foo..3;
+    like($msg,
+        qr/Argument "\*main::foo" isn't numeric in range \(or flop\)/,
+        "Got expected message about non-numeric argument in range"
+    );
+#    print STDERR "<$msg>";
+}
+
 # EOF

@p5pRT
Copy link
Author

p5pRT commented Dec 4, 2014

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

@p5pRT
Copy link
Author

p5pRT commented Dec 4, 2014

From @cpansprout

On Wed Dec 03 18​:53​:35 2014, jkeenan wrote​:

On Sun Sep 15 13​:40​:08 2013, sprout wrote​:

$ ./perl -Ilib -we '()=*foo..3'
Name "main​::foo" used only once​: possible typo at -e line 1.
Argument "*main​::foo" isn't numeric in range (or flop) at -e line 1.
Argument "*main​::foo" isn't numeric in range (or flop) at -e line 1.

As the patch attached shows, this problem seems to occur only on the
command-line -- not in a program in a file.

Your test isn’t counting how many times the warning occurs.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Dec 9, 2014

From @jkeenan

On Wed Dec 03 21​:47​:13 2014, sprout wrote​:

On Wed Dec 03 18​:53​:35 2014, jkeenan wrote​:

On Sun Sep 15 13​:40​:08 2013, sprout wrote​:

$ ./perl -Ilib -we '()=*foo..3'
Name "main​::foo" used only once​: possible typo at -e line 1.
Argument "*main​::foo" isn't numeric in range (or flop) at -e line 1.
Argument "*main​::foo" isn't numeric in range (or flop) at -e line 1.

As the patch attached shows, this problem seems to occur only on the
command-line -- not in a program in a file.

Your test isn’t counting how many times the warning occurs.

But if you uncomment the line beginning with 'print STDERR' and run this as you normally would for an individual file in the Perl 5 test suite, you will only get one instance of the warning.

#####
$ cd t;./perl harness op/range.t 2>../err; cd -;cat err
op/range.t .. ok
All tests successful.
Files=1, Tests=142, 0 wallclock secs ( 0.01 usr 0.00 sys + 0.01 cusr 0.00 csys = 0.02 CPU)
Result​: PASS
/home/jkeenan/gitwork/perl
<Argument "*main​::foo" isn't numeric in range (or flop) at op/range.t line 411.

#####

My point was that the problem originally described is, for some reason which I don't understand, only a command-line problem.

Thank you very much.
Jim Keenan
--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Dec 9, 2014

From @cpansprout

On Mon Dec 08 17​:52​:18 2014, jkeenan wrote​:

On Wed Dec 03 21​:47​:13 2014, sprout wrote​:

On Wed Dec 03 18​:53​:35 2014, jkeenan wrote​:

On Sun Sep 15 13​:40​:08 2013, sprout wrote​:

$ ./perl -Ilib -we '()=*foo..3'
Name "main​::foo" used only once​: possible typo at -e line 1.
Argument "*main​::foo" isn't numeric in range (or flop) at -e line
1.
Argument "*main​::foo" isn't numeric in range (or flop) at -e line
1.

As the patch attached shows, this problem seems to occur only on
the
command-line -- not in a program in a file.

Your test isn’t counting how many times the warning occurs.

But if you uncomment the line beginning with 'print STDERR' and run
this as you normally would for an individual file in the Perl 5 test
suite, you will only get one instance of the warning.

#####
$ cd t;./perl harness op/range.t 2>../err; cd -;cat err
op/range.t .. ok
All tests successful.
Files=1, Tests=142, 0 wallclock secs ( 0.01 usr 0.00 sys + 0.01
cusr 0.00 csys = 0.02 CPU)
Result​: PASS
/home/jkeenan/gitwork/perl
<Argument "*main​::foo" isn't numeric in range (or flop) at op/range.t
line 411.

#####

My point was that the problem originally described is, for some reason
which I don't understand, only a command-line problem.

Try applying the attached on top of your patch. You will see that $SIG{__WARN__} is firing twice.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Dec 9, 2014

From @cpansprout

Inline Patch
diff --git a/t/op/range.t b/t/op/range.t
index 99eb2a6..ab554e7 100644
--- a/t/op/range.t
+++ b/t/op/range.t
@@ -398,7 +398,7 @@ is( $s, '2345 2345','modifiable num counting loop counter' );
 {
     # test non-numeric warning in range (RT #119819)
     my $msg = '';
-    local $SIG{__WARN__} = sub { $msg = $_[0] };
+    local $SIG{__WARN__} = sub { print STDERR "warning!\n"; $msg .= $_[0] };
     use warnings;
     () = *foo..3;
     like($msg,

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

No branches or pull requests

2 participants