]> Cypherpunks repositories - gostls13.git/commit
text/scanner: don't liberally consume (invalid) floats or underbars
authorRobert Griesemer <gri@golang.org>
Wed, 20 Feb 2019 18:44:52 +0000 (10:44 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 20 Feb 2019 20:23:28 +0000 (20:23 +0000)
commit34fb5855eb73fe04ee0bcfc0d9ca8be5440a560b
treef453b91c88ae53aa14b6759a9bdd9cd1353721cc
parent153c0da89bca6726545cf4451053235b552d3d51
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>
api/except.txt
api/next.txt
src/text/scanner/scanner.go
src/text/scanner/scanner_test.go