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

Some incomplete expressions treated as valid #17010

Closed
p5pRT opened this issue May 22, 2019 · 11 comments
Closed

Some incomplete expressions treated as valid #17010

p5pRT opened this issue May 22, 2019 · 11 comments
Labels

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented May 22, 2019

Migrated from rt.perl.org#134125 (status was 'pending release')

Searchable as RT134125$

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented May 22, 2019

From @khwilliamson

This is a bug report for perl from khw@​khw-xps-8930.(none),
generated with the help of perlbug 1.41 running under perl 5.31.0.


These cases are extracted from [perl #112084]
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=112084

filed by Tom Christiansen, the rest of which has been fixed or rejected.

% blead -wle 'print 0x - 1'
1
% blead -wle 'print 0b - 1'
-1
% blead -wle 'print 0xx2'
00

Surely that's again an error? Those are the same kind of thing as this​:

% blead -wle 'print 3.14e'
Bareword found where operator expected at -e line 1, near "3.14e"
(Missing operator before e?) Unquoted string "e" may clash with future
reserved word at -e line 1. syntax error at -e line 1, near "3.14e "
Execution of -e aborted due to compilation errors.
Exit 255

--tom



Flags​:
  category=core
  severity=low


Site configuration information for perl 5.31.0​:

Configured by khw at Wed May 22 08​:58​:17 MDT 2019.

Summary of my perl5 (revision 5 version 31 subversion 0) configuration​:
  Commit id​: 58f4626
  Platform​:
  osname=linux
  osvers=4.15.0-50-generic
  archname=x86_64-linux-thread-multi
  uname='linux khw-xps-8930 4.15.0-50-generic #54-ubuntu smp mon may
6 18​:46​:08 utc 2019 x86_64 x86_64 x86_64 gnulinux '
  config_args='-des -Uversiononly -Dprefix=/home/khw/blead -Dusedevel
-A'optimize=-ggdb3' -A'optimize=-O0' -Accflags='-Wno-deprecated'
-Dman1dir=none -Dman3dir=none -Dcc=g++ -DDEBUGGING -Dusecbacktrace
-Dusethreads'
  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='g++'
  ccflags ='-D_REENTRANT -D_GNU_SOURCE -Wno-deprecated -fwrapv
-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong
-I/usr/local/include -DUSE_C_BACKTRACE -g -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
  optimize='-O2 -ggdb3 -O0'
  cppflags='-D_REENTRANT -D_GNU_SOURCE -Wno-deprecated -fwrapv
-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong
-I/usr/local/include'
  ccversion=''
  gccversion='7.4.0'
  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='g++'
  ldflags =' -fstack-protector-strong -L/usr/local/lib'
  libpth=/usr/include/c++/7 /usr/include/x86_64-linux-gnu/c++/7
/usr/include/c++/7/backward /usr/local/lib
/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
/usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib
/usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
  libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
  perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
  libc=libc-2.27.so
  so=so
  useshrplib=false
  libperl=libperl.a
  gnulibc_version='2.27'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs
  dlext=so
  d_dlsymun=undef
  ccdlflags='-Wl,-E'
  cccdlflags='-fPIC'
  lddlflags='-shared -O2 -ggdb3 -O0 -L/usr/local/lib
-fstack-protector-strong'


@​INC for perl 5.31.0​:
  /home/khw/perl/blead/lib
  /home/khw/perl/blead/t
  /home/khw/blead/lib/perl5/site_perl/5.31.0/x86_64-linux-thread-multi
  /home/khw/blead/lib/perl5/site_perl/5.31.0
  /home/khw/blead/lib/perl5/5.31.0/x86_64-linux-thread-multi
  /home/khw/blead/lib/perl5/5.31.0
  /home/khw/blead/lib/perl5/site_perl/5.30.0
  /home/khw/blead/lib/perl5/site_perl/5.29.10
  /home/khw/blead/lib/perl5/site_perl/5.29.9
  /home/khw/blead/lib/perl5/site_perl/5.29.8
  /home/khw/blead/lib/perl5/site_perl/5.29.7
  /home/khw/blead/lib/perl5/site_perl/5.29.6
  /home/khw/blead/lib/perl5/site_perl/5.29.5
  /home/khw/blead/lib/perl5/site_perl/5.29.4
  /home/khw/blead/lib/perl5/site_perl/5.29.3
  /home/khw/blead/lib/perl5/site_perl/5.29.2
  /home/khw/blead/lib/perl5/site_perl/5.29.1
  /home/khw/blead/lib/perl5/site_perl/5.29.0
  /home/khw/blead/lib/perl5/site_perl/5.28.0
  /home/khw/blead/lib/perl5/site_perl/5.27.11
  /home/khw/blead/lib/perl5/site_perl/5.27.10
  /home/khw/blead/lib/perl5/site_perl/5.27.9
  /home/khw/blead/lib/perl5/site_perl/5.27.8
  /home/khw/blead/lib/perl5/site_perl/5.27.7
  /home/khw/blead/lib/perl5/site_perl/5.27.6
  /home/khw/blead/lib/perl5/site_perl/5.27.5
  /home/khw/blead/lib/perl5/site_perl/5.27.4
  /home/khw/blead/lib/perl5/site_perl/5.27.3
  /home/khw/blead/lib/perl5/site_perl/5.27.2
  /home/khw/blead/lib/perl5/site_perl/5.27.1
  /home/khw/blead/lib/perl5/site_perl/5.27.0
  /home/khw/blead/lib/perl5/site_perl/5.26.0
  /home/khw/blead/lib/perl5/site_perl/5.25.12
  /home/khw/blead/lib/perl5/site_perl/5.25.11
  /home/khw/blead/lib/perl5/site_perl/5.25.10
  /home/khw/blead/lib/perl5/site_perl/5.25.9
  /home/khw/blead/lib/perl5/site_perl/5.25.8
  /home/khw/blead/lib/perl5/site_perl/5.25.7
  /home/khw/blead/lib/perl5/site_perl/5.25.6
  /home/khw/blead/lib/perl5/site_perl/5.25.5
  /home/khw/blead/lib/perl5/site_perl/5.25.4
  /home/khw/blead/lib/perl5/site_perl/5.25.3
  /home/khw/blead/lib/perl5/site_perl/5.25.2
  /home/khw/blead/lib/perl5/site_perl/5.25.1
  /home/khw/blead/lib/perl5/site_perl/5.24.0
  /home/khw/blead/lib/perl5/site_perl/5.23.10
  /home/khw/blead/lib/perl5/site_perl/5.23.9
  /home/khw/blead/lib/perl5/site_perl/5.23.8
  /home/khw/blead/lib/perl5/site_perl/5.23.7
  /home/khw/blead/lib/perl5/site_perl/5.23.6
  /home/khw/blead/lib/perl5/site_perl/5.23.5
  /home/khw/blead/lib/perl5/site_perl/5.23.4
  /home/khw/blead/lib/perl5/site_perl/5.23.3
  /home/khw/blead/lib/perl5/site_perl/5.23.2
  /home/khw/blead/lib/perl5/site_perl/5.23.1
  /home/khw/blead/lib/perl5/site_perl/5.23.0
  /home/khw/blead/lib/perl5/site_perl/5.22.0
  /home/khw/blead/lib/perl5/site_perl/5.21.12
  /home/khw/blead/lib/perl5/site_perl/5.21.11
  /home/khw/blead/lib/perl5/site_perl/5.21.10
  /home/khw/blead/lib/perl5/site_perl/5.21.9
  /home/khw/blead/lib/perl5/site_perl/5.21.8
  /home/khw/blead/lib/perl5/site_perl/5.21.7
  /home/khw/blead/lib/perl5/site_perl/5.21.6
  /home/khw/blead/lib/perl5/site_perl/5.21.5
  /home/khw/blead/lib/perl5/site_perl/5.21.4
  /home/khw/blead/lib/perl5/site_perl/5.21.3
  /home/khw/blead/lib/perl5/site_perl/5.21.2
  /home/khw/blead/lib/perl5/site_perl/5.21.1
  /home/khw/blead/lib/perl5/site_perl/5.20.0
  /home/khw/blead/lib/perl5/site_perl/5.19.12
  /home/khw/blead/lib/perl5/site_perl/5.19.11
  /home/khw/blead/lib/perl5/site_perl/5.19.10
  /home/khw/blead/lib/perl5/site_perl


Environment for perl 5.31.0​:
  HOME=/home/khw
  LANG=en_US.UTF-8
  LANGUAGE=en
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)

PATH=/usr/lib/ccache​:/home/khw/bin​:/home/khw/perl5/perlbrew/bin​:/home/khw/print/bin​:/bin​:/usr/local/sbin​:/usr/local/bin​:/usr/sbin​:/usr/bin​:/sbin​:/usr/games​:/usr/local/games​:/snap/bin​:/home/khw/iands/www​:/home/khw/cxoffice/bin
  PERL5OPT=
  PERL_BADLANG (unset)
  PERL_DIFF_TOOL=wgdiff
  PERL_POD_PEDANTIC=1
  SHELL=/usr/bin/ksh

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 4, 2019

From @tonycoz

On Wed, 22 May 2019 11​:33​:05 -0700, public@​khwilliamson.com wrote​:

These cases are extracted from [perl #112084]
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=112084

filed by Tom Christiansen, the rest of which has been fixed or
rejected.

% blead -wle 'print 0x - 1'
1
% blead -wle 'print 0b - 1'
-1
% blead -wle 'print 0xx2'
00

Surely that's again an error? Those are the same kind of thing as
this​:

% blead -wle 'print 3.14e'
Bareword found where operator expected at -e line 1, near "3.14e"
(Missing operator before e?) Unquoted string "e" may clash with future
reserved word at -e line 1. syntax error at -e line 1, near "3.14e "
Execution of -e aborted due to compilation errors.
Exit 255

Something like the attached?

Tony

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 4, 2019

From @tonycoz

0001-perl-134125-accept-only-complete-hex-and-binary-lite.patch
From 4d409f4671be0c6b879a163c0a364c9516789117 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Tue, 4 Jun 2019 16:35:35 +1000
Subject: (perl #134125) accept only complete hex and binary literals

---
 t/lib/croak/toke    | 16 ++++++++++++++++
 t/lib/warnings/toke |  3 ---
 t/op/hexfp.t        |  4 ++--
 toke.c              |  9 +++++++++
 4 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/t/lib/croak/toke b/t/lib/croak/toke
index 21851229fe..70d307b0c4 100644
--- a/t/lib/croak/toke
+++ b/t/lib/croak/toke
@@ -502,3 +502,19 @@ format=
 EXPECT
 syntax error at - line 4, next token ???
 Execution of - aborted due to compilation errors.
+########
+# NAME [perl #134045] incomplete hex number
+0x x 2;
+0xx 2;
+0x_;
+EXPECT
+Number found where operator expected at - line 1, near "x 2"
+	(Do you need to predeclare x?)
+Bareword found where operator expected at - line 2, near "0xx"
+	(Missing operator before xx?)
+Number found where operator expected at - line 2, near "xx 2"
+	(Do you need to predeclare xx?)
+Bareword found where operator expected at - line 3, near "0x_"
+	(Missing operator before x_?)
+syntax error at - line 1, near "x 2"
+Execution of - aborted due to compilation errors.
diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke
index 83641e5106..5343e957ba 100644
--- a/t/lib/warnings/toke
+++ b/t/lib/warnings/toke
@@ -756,7 +756,6 @@ $a = 1_; print "$a\n";
 $a = 01_; print "$a\n";
 $a = 0_; print "$a\n";
 $a = 0x1_; print "$a\n";
-$a = 0x_; print "$a\n";
 $a = 1.2_; print "$a\n";
 $a = 1._2; print "$a\n";
 $a = 1._; print "$a\n";
@@ -768,12 +767,10 @@ Misplaced _ in number at - line 6.
 Misplaced _ in number at - line 7.
 Misplaced _ in number at - line 8.
 Misplaced _ in number at - line 9.
-Misplaced _ in number at - line 10.
 1
 1
 0
 1
-0
 1.2
 1.2
 1
diff --git a/t/op/hexfp.t b/t/op/hexfp.t
index 64f81364b7..8904c48d29 100644
--- a/t/op/hexfp.t
+++ b/t/op/hexfp.t
@@ -138,7 +138,7 @@ sub get_warn() {
 
 { # Test certain things that are not hexfloats and should stay that way.
     eval '0xp3';
-    like(get_warn(), qr/Missing operator before p3/);
+    like(get_warn(), qr/Missing operator before xp3/);
 
     eval '5p3';
     like(get_warn(), qr/Missing operator before p3/);
@@ -149,7 +149,7 @@ sub get_warn() {
 
     undef $a;
     eval '$a = eval "0x.3"';
-    is($a, '03');
+    is($a, ''); # 0 x .3
 
     undef $a;
     eval '$a = eval "0xc.3"';
diff --git a/toke.c b/toke.c
index cecfa82378..67a31a9b93 100644
--- a/toke.c
+++ b/toke.c
@@ -11025,6 +11025,7 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp)
 	    I32 shift;
 	    bool overflowed = FALSE;
 	    bool just_zero  = TRUE;	/* just plain 0 or binary number? */
+            bool has_digs = FALSE;
 	    static const NV nvshift[5] = { 1.0, 2.0, 4.0, 8.0, 16.0 };
 	    static const char* const bases[5] =
 	      { "", "binary", "", "octal", "hexadecimal" };
@@ -11116,6 +11117,7 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp)
 
 		  digit:
 		    just_zero = FALSE;
+                    has_digs = TRUE;
 		    if (!overflowed) {
 			assert(shift >= 0);
 			x = u << shift;	/* make room for the digit */
@@ -11331,6 +11333,13 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp)
                 }
             }
 
+            if (shift != 3 && !has_digs) {
+                /* 0x or 0b with no digits, treat it as if the x or b is part of the
+                   next token
+                */
+                s = start + 1;
+            }
+
 	    if (overflowed) {
 		if (n > 4294967295.0)
 		    Perl_ck_warner(aTHX_ packWARN(WARN_PORTABLE),
-- 
2.11.0

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 4, 2019

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

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 12, 2019

From @tonycoz

On Mon, 03 Jun 2019 23​:36​:37 -0700, tonyc wrote​:

On Wed, 22 May 2019 11​:33​:05 -0700, public@​khwilliamson.com wrote​:

These cases are extracted from [perl #112084]
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=112084

filed by Tom Christiansen, the rest of which has been fixed or
rejected.

% blead -wle 'print 0x - 1'
1
% blead -wle 'print 0b - 1'
-1
% blead -wle 'print 0xx2'
00

Surely that's again an error? Those are the same kind of thing as
this​:

% blead -wle 'print 3.14e'
Bareword found where operator expected at -e line 1, near "3.14e"
(Missing operator before e?) Unquoted string "e" may clash with future
reserved word at -e line 1. syntax error at -e line 1, near "3.14e "
Execution of -e aborted due to compilation errors.
Exit 255

Something like the attached?

Applied as 7259f41.

Tony

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 12, 2019

@tonycoz - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 20, 2019

@tonycoz - Status changed from 'pending release' to 'open'

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 20, 2019

From @tonycoz

On Tue, 11 Jun 2019 17​:18​:10 -0700, tonyc wrote​:

On Mon, 03 Jun 2019 23​:36​:37 -0700, tonyc wrote​:

On Wed, 22 May 2019 11​:33​:05 -0700, public@​khwilliamson.com wrote​:

These cases are extracted from [perl #112084]
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=112084

filed by Tom Christiansen, the rest of which has been fixed or
rejected.

% blead -wle 'print 0x - 1'
1
% blead -wle 'print 0b - 1'
-1
% blead -wle 'print 0xx2'
00

Surely that's again an error? Those are the same kind of thing as
this​:

% blead -wle 'print 3.14e'
Bareword found where operator expected at -e line 1, near "3.14e"
(Missing operator before e?) Unquoted string "e" may clash with future
reserved word at -e line 1. syntax error at -e line 1, near "3.14e "
Execution of -e aborted due to compilation errors.
Exit 255

Something like the attached?

Applied as 7259f41.

After some thought, I'd prefer to make this fatal instead.

In most cases adjusting the parse position will result in a later syntax error, but in a few cases with 0x it can result in a silent change in behaviour instead, which is bad.

The attached makes this fatal.

Tony

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 20, 2019

From @tonycoz

0001-perl-134125-make-no-digits-after-0x-0b-fatal.patch
From 76edcdedd4305d2c6c57d0116dabe9aa2c91bd9e Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Thu, 20 Jun 2019 11:06:13 +1000
Subject: (perl #134125) make no digits after 0x/0b fatal

My original change in 7259f4194 silently adjusted the parse
position to immediately after the 0 in an incomplete hex or binary
literal.  In most cases this leads to a syntax error, but in some
cases, especially with 0x, this can lead to a silent change in
behaviour.

So throw an error instead.
---
 pod/perldiag.pod |  5 +++++
 t/lib/croak/toke | 14 +++++---------
 t/op/hexfp.t     |  4 ++--
 toke.c           | 12 +++++++++---
 4 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 166d29b4bb..325bfce50f 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -4100,6 +4100,11 @@ for some reason the current debugger (e.g. F<perl5db.pl> or a C<Devel::>
 module) didn't define a C<DB::sub> routine to be called at the beginning
 of each ordinary subroutine call.
 
+=item No digits found for %s literal
+
+(F) No hexadecimal digits were found following C<0x> or no binary digits
+were found following C<0b>.
+
 =item No directory specified for -I
 
 (F) The B<-I> command-line switch requires a directory name as part of the
diff --git a/t/lib/croak/toke b/t/lib/croak/toke
index e7bf609637..4ef6f726fc 100644
--- a/t/lib/croak/toke
+++ b/t/lib/croak/toke
@@ -507,16 +507,12 @@ Execution of - aborted due to compilation errors.
 0x x 2;
 0xx 2;
 0x_;
+0b;
 EXPECT
-Number found where operator expected at - line 1, near "x 2"
-	(Do you need to predeclare x?)
-Bareword found where operator expected at - line 2, near "0xx"
-	(Missing operator before xx?)
-Number found where operator expected at - line 2, near "xx 2"
-	(Do you need to predeclare xx?)
-Bareword found where operator expected at - line 3, near "0x_"
-	(Missing operator before x_?)
-syntax error at - line 1, near "x 2"
+No digits found for hexadecimal literal at - line 1, near "0x "
+No digits found for hexadecimal literal at - line 2, near "0xx"
+No digits found for hexadecimal literal at - line 3, near "0x_;"
+No digits found for binary literal at - line 4, near "0b;"
 Execution of - aborted due to compilation errors.
 ########
 # NAME [perl #130585] close paren in subparse
diff --git a/t/op/hexfp.t b/t/op/hexfp.t
index 8904c48d29..eeb2c9d364 100644
--- a/t/op/hexfp.t
+++ b/t/op/hexfp.t
@@ -138,7 +138,7 @@ sub get_warn() {
 
 { # Test certain things that are not hexfloats and should stay that way.
     eval '0xp3';
-    like(get_warn(), qr/Missing operator before xp3/);
+    like(get_warn(), qr/Missing operator before p3/);
 
     eval '5p3';
     like(get_warn(), qr/Missing operator before p3/);
@@ -149,7 +149,7 @@ sub get_warn() {
 
     undef $a;
     eval '$a = eval "0x.3"';
-    is($a, ''); # 0 x .3
+    is($a, undef); # throws an error
 
     undef $a;
     eval '$a = eval "0xc.3"';
diff --git a/toke.c b/toke.c
index 694b008761..753f3cbeeb 100644
--- a/toke.c
+++ b/toke.c
@@ -11336,10 +11336,16 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp)
             }
 
             if (shift != 3 && !has_digs) {
-                /* 0x or 0b with no digits, treat it as if the x or b is part of the
-                   next token
+                /* 0x or 0b with no digits, treat it as an error.
+                   Originally this backed up the parse before the b or
+                   x, but that has the potential for silent changes in
+                   behaviour, like for: "0x.3" and "0x+$foo".
                 */
-                s = start + 1;
+                const char *d = s;
+                if (*d) ++d; /* so the user sees the bad non-digit */
+                PL_bufptr = (char *)d; /* so yyerror reports the context */
+                yyerror(Perl_form(aTHX_ "No digits found for %s literal",
+                                  shift == 4 ? "hexadecimal" : "binary"));
             }
 
 	    if (overflowed) {
-- 
2.11.0

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 27, 2019

From @tonycoz

On Wed, 19 Jun 2019 18​:08​:28 -0700, tonyc wrote​:

On Tue, 11 Jun 2019 17​:18​:10 -0700, tonyc wrote​:

On Mon, 03 Jun 2019 23​:36​:37 -0700, tonyc wrote​:

On Wed, 22 May 2019 11​:33​:05 -0700, public@​khwilliamson.com wrote​:

These cases are extracted from [perl #112084]
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=112084

filed by Tom Christiansen, the rest of which has been fixed or
rejected.

% blead -wle 'print 0x - 1'
1
% blead -wle 'print 0b - 1'
-1
% blead -wle 'print 0xx2'
00

Surely that's again an error? Those are the same kind of thing as
this​:

% blead -wle 'print 3.14e'
Bareword found where operator expected at -e line 1, near "3.14e"
(Missing operator before e?) Unquoted string "e" may clash with
future
reserved word at -e line 1. syntax error at -e line 1, near
"3.14e "
Execution of -e aborted due to compilation errors.
Exit 255

Something like the attached?

Applied as 7259f41.

After some thought, I'd prefer to make this fatal instead.

In most cases adjusting the parse position will result in a later
syntax error, but in a few cases with 0x it can result in a silent
change in behaviour instead, which is bad.

The attached makes this fatal.

Applied as 1ef28cc.

Tony

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 27, 2019

@tonycoz - Status changed from 'open' to 'pending release'

@p5pRT p5pRT closed this Jun 27, 2019
@p5pRT p5pRT added the Severity Low label Oct 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.