compiler: better error for unexpected digit
A digit character is not invalid in general, but it's not permitted at the start of an identifier. Report a better error message. The test case is issue11359.go in the source repo. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/278174
This commit is contained in:
parent
a582a319c1
commit
f23753c710
2 changed files with 8 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
3e8f49a2137a87fdaba51c3002ddbe41ab18ed46
|
||||
8b913a1865e36d4bd105f29aa0b12264a4e03515
|
||||
|
||||
The first line of this file holds the git revision number of the last
|
||||
merge done from the gofrontend repository.
|
||||
|
|
|
@ -743,6 +743,13 @@ Lex::next_token()
|
|||
if (Lex::is_unicode_letter(ci))
|
||||
return this->gather_identifier();
|
||||
|
||||
if (!issued_error && Lex::is_unicode_digit(ci))
|
||||
{
|
||||
go_error_at(this->location(),
|
||||
"identifier cannot begin with digit");
|
||||
issued_error = true;
|
||||
}
|
||||
|
||||
if (!issued_error)
|
||||
go_error_at(this->location(),
|
||||
"invalid character 0x%x in input file",
|
||||
|
|
Loading…
Add table
Reference in a new issue