-
Notifications
You must be signed in to change notification settings - Fork 17.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/types, types2: avoid spurious "undefined" errors" for invalid iden…
…tifiers The syntax parser complains about invalid identifiers. Don't report a typechecker error when such an identifier cannot be found in the current scope. For now add a local test for types2 only because the go/parser behaves differently than the syntax parser which leads to slightly different error positions. Fixes #68183. Change-Id: Idbfe62fafcd704886069182744ec5e6b37ffc4e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/602476 Auto-Submit: Robert Griesemer <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Tim King <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
- Loading branch information
Showing
7 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/cmd/compile/internal/types2/testdata/local/issue68183.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2024 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. | ||
|
||
// Test that invalid identifiers reported by the parser | ||
// don't lead to additional errors during typechecking. | ||
|
||
package p | ||
|
||
import "fmt" | ||
|
||
var ( | ||
☹x /* ERROR "invalid character" */ int | ||
_ = ☹x // ERROR "invalid character" | ||
_ = fmt.☹x // ERROR "invalid character" | ||
_ = ☹fmt /* ERROR "invalid character" */ .Println | ||
_ = _世界 // ERROR "undefined: _世界" | ||
_ = ☹_世界 // ERROR "invalid character" | ||
) | ||
|
||
func ☹m /* ERROR "invalid character" */ () {} | ||
|
||
type T struct{} | ||
func (T) ☹m /* ERROR "invalid character" */ () {} | ||
|
||
func _() { | ||
var x T | ||
x.☹m /* ERROR "invalid character" */ () | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters