cmd/compile: use quotes to wrap user-supplied token

This commit is contained in:
Zxilly 2024-02-21 18:28:26 +08:00
parent d4112310a4
commit f7a348e75a
2 changed files with 17 additions and 1 deletions

View File

@ -267,7 +267,9 @@ func (p *parser) syntaxErrorAt(pos Pos, msg string) {
// determine token string
var tok string
switch p.tok {
case _Name, _Semi:
case _Name:
tok = "\"" + p.lit + "\""
case _Semi:
tok = p.lit
case _Literal:
tok = "literal " + p.lit

View File

@ -0,0 +1,14 @@
// Copyright 2023 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.
package p
import (
"fmt"
)
func f() {
int status // ERROR syntax error: unexpected "status" at end of statement
fmt.Println(status)
}