aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/typecheck.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2020-12-29 19:46:31 -0800
committerMatthew Dempsky <mdempsky@google.com>2020-12-30 04:24:02 +0000
commitf9b67f76a59cb9adf5d04e9b559cda98afb3c6f4 (patch)
tree1a7cda5af5f4a0a240731e47dbeab510f26f6277 /src/cmd/compile/internal/typecheck/typecheck.go
parent499851bac88dfa2a85c39a2123f092071098cada (diff)
downloadgo-f9b67f76a59cb9adf5d04e9b559cda98afb3c6f4.tar.gz
go-f9b67f76a59cb9adf5d04e9b559cda98afb3c6f4.zip
[dev.regabi] cmd/compile: change ir.DoChildren to use bool result type
After using the IR visitor code for a bit, it seems clear that a simple boolean result type is adequate for tree traversals. This CL updates ir.DoChildren to use the same calling convention as ir.Any, and updates mknode.go to generate code accordingly. There were only two places where the error-based DoChildren API was used within the compiler: 1. Within typechecking, marking statements that contain "break". This code never returns errors anyway, so it's trivially updated to return false instead. 2. Within inlining, the "hairy visitor" actually does make use of returning errors. However, it threads through a reference to the hairyVisitor anyway, where it would be trivial to store any needed information instead. For the purpose of this CL, we provide "errChildren" and "errList" helper functions that provide the previous error-based semantics on top of the new bool-based API. Passes toolstash -cmp. Change-Id: I4bac9a697b4dbfb5f66eeac37d4a2ced2073d7d0 Reviewed-on: https://go-review.googlesource.com/c/go/+/280675 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/typecheck.go')
-rw-r--r--src/cmd/compile/internal/typecheck/typecheck.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go
index 480d2de8e3..ebdcc4a72e 100644
--- a/src/cmd/compile/internal/typecheck/typecheck.go
+++ b/src/cmd/compile/internal/typecheck/typecheck.go
@@ -2053,8 +2053,8 @@ func markBreak(fn *ir.Func) {
var labels map[*types.Sym]ir.Node
var implicit ir.Node
- var mark func(ir.Node) error
- mark = func(n ir.Node) error {
+ var mark func(ir.Node) bool
+ mark = func(n ir.Node) bool {
switch n.Op() {
default:
ir.DoChildren(n, mark)
@@ -2094,7 +2094,7 @@ func markBreak(fn *ir.Func) {
}
implicit = old
}
- return nil
+ return false
}
mark(fn)