Commit 247959d9 authored by Russ Cox's avatar Russ Cox

cmd/compile: reject identifiers beginning with non-ASCII digit

Fixes #11359.

Change-Id: I0fdfa410939f7e42020cbb19d74a67e1cc3cd610
Reviewed-on: https://go-review.googlesource.com/16919Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent f2eb3de6
...@@ -1469,6 +1469,9 @@ talph: ...@@ -1469,6 +1469,9 @@ talph:
if !unicode.IsLetter(r) && !unicode.IsDigit(r) && (importpkg == nil || r != 0xb7) { if !unicode.IsLetter(r) && !unicode.IsDigit(r) && (importpkg == nil || r != 0xb7) {
Yyerror("invalid identifier character U+%04x", r) Yyerror("invalid identifier character U+%04x", r)
} }
if cp.Len() == 0 && unicode.IsDigit(r) {
Yyerror("identifier cannot begin with digit U+%04x", r)
}
cp.WriteRune(r) cp.WriteRune(r)
} else if !isAlnum(c) && c != '_' { } else if !isAlnum(c) && c != '_' {
break break
......
// errorcheck
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// identifiers beginning with non-ASCII digits were incorrectly accepted.
// issue 11359.
package p
var ۶ = 0 // ERROR "identifier cannot begin with digit"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment