• Robert Griesemer's avatar
    text/scanner: don't liberally consume (invalid) floats or underbars · 34fb5855
    Robert Griesemer authored
    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/163079Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
    34fb5855
next.txt 137 Bytes