From 3cf56e78d812069d2ffb65b5c29a76961b0b0af8 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 29 Jan 2019 23:21:29 -0500 Subject: text/template: accept new number syntax This CL updates text/template's scanner to accept the new number syntaxes: - Hexadecimal floating-point values. - Digit-separating underscores. - Leading 0b and 0o prefixes. See golang.org/design/19308-number-literals for background. For #12711. For #19308. For #28493. For #29008. Change-Id: I68c16ea35c3f506701063781388de72bafee6b8d Reviewed-on: https://go-review.googlesource.com/c/160248 Reviewed-by: Rob Pike Reviewed-by: Robert Griesemer --- src/text/template/parse/node.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/text/template/parse/node.go') diff --git a/src/text/template/parse/node.go b/src/text/template/parse/node.go index dca83dacce..1174a4b970 100644 --- a/src/text/template/parse/node.go +++ b/src/text/template/parse/node.go @@ -596,7 +596,7 @@ func (t *Tree) newNumber(pos Pos, text string, typ itemType) (*NumberNode, error if err == nil { // If we parsed it as a float but it looks like an integer, // it's a huge number too large to fit in an int. Reject it. - if !strings.ContainsAny(text, ".eE") { + if !strings.ContainsAny(text, ".eEpP") { return nil, fmt.Errorf("integer overflow: %q", text) } n.IsFloat = true -- cgit v1.3-6-g1900