diff options
author | Robert Griesemer <gri@golang.org> | 2019-02-20 10:44:52 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2019-02-20 20:23:28 +0000 |
commit | 34fb5855eb73fe04ee0bcfc0d9ca8be5440a560b (patch) | |
tree | f453b91c88ae53aa14b6759a9bdd9cd1353721cc /api | |
parent | 153c0da89bca6726545cf4451053235b552d3d51 (diff) | |
download | go-34fb5855eb73fe04ee0bcfc0d9ca8be5440a560b.tar.gz go-34fb5855eb73fe04ee0bcfc0d9ca8be5440a560b.zip |
text/scanner: don't liberally consume (invalid) floats or underbars
This is a follow-up on https://golang.org/cl/161199 which introduced
the new Go 2 number literals to text/scanner.
That change introduced a bug by allowing decimal and hexadecimal floats
to be consumed even if the scanner was not configured to accept floats.
This CL changes the code to not consume a radix dot '.' or exponent
unless the scanner is configured to accept floats.
This CL also introduces a new mode "AllowNumberbars" which controls
whether underbars '_' are permitted as digit separators in numbers
or not.
There is a possibility that we may need to refine text/scanner
further (e.g., the Float mode now includes hexadecimal floats
which it didn't recognize before). We're very early in the cycle,
so let's see how it goes.
RELNOTE=yes
Updates #12711.
Updates #19308.
Updates #28493.
Updates #29008.
Fixes #30320.
Change-Id: I6481d314f0384e09ef6803ffad38dc529b1e89a3
Reviewed-on: https://go-review.googlesource.com/c/163079
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'api')
-rw-r--r-- | api/except.txt | 1 | ||||
-rw-r--r-- | api/next.txt | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/api/except.txt b/api/except.txt index 637be18135..a608d5783e 100644 --- a/api/except.txt +++ b/api/except.txt @@ -457,3 +457,4 @@ pkg syscall (freebsd-arm-cgo), type Stat_t struct, Nlink uint16 pkg syscall (freebsd-arm-cgo), type Stat_t struct, Rdev uint32 pkg syscall (freebsd-arm-cgo), type Statfs_t struct, Mntfromname [88]int8 pkg syscall (freebsd-arm-cgo), type Statfs_t struct, Mntonname [88]int8 +pkg text/scanner, const GoTokens = 1012
\ No newline at end of file diff --git a/api/next.txt b/api/next.txt index e69de29bb2..aaea62d70b 100644 --- a/api/next.txt +++ b/api/next.txt @@ -0,0 +1,3 @@ +pkg text/scanner, const AllowNumberbars = 1024 +pkg text/scanner, const AllowNumberbars ideal-int +pkg text/scanner, const GoTokens = 2036 |