aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/nodes.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2018-03-29 18:22:23 -0700
committerRobert Griesemer <gri@golang.org>2018-04-03 05:34:20 +0000
commitc65a2781be7a8029435ea3d6a3c54c601ac4ba3e (patch)
treeb7017c568143e1aca93a23af43603da4209e9be8 /src/cmd/compile/internal/syntax/nodes.go
parent071f0de4ec0d912b2908821466818ca2be04655c (diff)
downloadgo-c65a2781be7a8029435ea3d6a3c54c601ac4ba3e.tar.gz
go-c65a2781be7a8029435ea3d6a3c54c601ac4ba3e.zip
cmd/compile: better handling of incorrect type switches
Don't report errors if we don't have a correct type switch guard; instead ignore it and leave it to the type-checker to report the error. This leads to better error messages concentrating on the type switch guard rather than errors around (confusing) syntactic details. Also clean up some code setting up AssertExpr (they never have a nil Type field) and remove some incorrect TODOs. Fixes #24470. Change-Id: I69512f36e0417e3b5ea9c8856768e04b19d654a8 Reviewed-on: https://go-review.googlesource.com/103615 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax/nodes.go')
-rw-r--r--src/cmd/compile/internal/syntax/nodes.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/cmd/compile/internal/syntax/nodes.go b/src/cmd/compile/internal/syntax/nodes.go
index 8df9fd5c4e..c1da4adf52 100644
--- a/src/cmd/compile/internal/syntax/nodes.go
+++ b/src/cmd/compile/internal/syntax/nodes.go
@@ -198,12 +198,19 @@ type (
// X.(Type)
AssertExpr struct {
- X Expr
- // TODO(gri) consider using Name{"..."} instead of nil (permits attaching of comments)
+ X Expr
Type Expr
expr
}
+ // X.(type)
+ // Lhs := X.(type)
+ TypeSwitchGuard struct {
+ Lhs *Name // nil means no Lhs :=
+ X Expr // X.(type)
+ expr
+ }
+
Operation struct {
Op Operator
X, Y Expr // Y == nil means unary expression
@@ -413,13 +420,6 @@ type (
simpleStmt
}
- TypeSwitchGuard struct {
- // TODO(gri) consider using Name{"..."} instead of nil (permits attaching of comments)
- Lhs *Name // nil means no Lhs :=
- X Expr // X.(type)
- expr
- }
-
CaseClause struct {
Cases Expr // nil means default clause
Body []Stmt