mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: do branch/label checks only once
The previous change implemented the missing fallthrough checking in the parser. Therefore we can now disable the duplicate check in the type checker: - rename (types2.Config.)IngoreLabels to IgnoreBranches to more accurately reflect its functionality - now also ignore break/continue/fallthroughs, not just labels The IgnoreBranches flag only exists for types2, for use with the compiler. There's no need to port this code to go/types. Note: An alternative (and perhaps better) approach would be to not use the the parser's CheckBranches mode and instead enable (i.e. not disable) the branch/label checking in the type checker. However, this requires a bit more work because the type checker's error messages about goto's jumping over variables don't have access to the variable names, which are desired in the error messages. Fixes #51456. Change-Id: Ib2e71e811d4e84e4895b729646e879fd43b12dcd Reviewed-on: https://go-review.googlesource.com/c/go/+/414135 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
This commit is contained in:
parent
6b309be7ab
commit
666d736ecb
4 changed files with 10 additions and 18 deletions
|
|
@ -41,7 +41,7 @@ func checkFiles(noders []*noder) (posMap, *types2.Package, *types2.Info) {
|
|||
conf := types2.Config{
|
||||
Context: ctxt,
|
||||
GoVersion: base.Flag.Lang,
|
||||
IgnoreLabels: true, // parser already checked via syntax.CheckBranches mode
|
||||
IgnoreBranchErrors: true, // parser already checked via syntax.CheckBranches mode
|
||||
CompilerErrorMessages: true, // use error strings matching existing compiler errors
|
||||
Error: func(err error) {
|
||||
terr := err.(types2.Error)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue