From d159d6108c4d7ba962bb6eea13f06590a76ac9e8 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 5 Jun 2018 10:19:03 -0700 Subject: [PATCH] cmd/compile: terminate compilation if type-checking fails There is no benefit in continuing compilation if there are type-checking errors. This will increase robustness of the compiler in the presence of errors. Fixes #22909. Change-Id: I1c70c667e5927646ba3d0f370e33705165620f12 Reviewed-on: https://go-review.googlesource.com/116335 Reviewed-by: Ian Lance Taylor --- src/cmd/compile/internal/gc/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index e9d9e5566e..e8b33008b4 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -532,6 +532,10 @@ func Main(archInit func(*Arch)) { checkMapKeys() timings.AddEvent(fcount, "funcs") + if nsavederrors+nerrors != 0 { + errorexit() + } + // Phase 4: Decide how to capture closed variables. // This needs to run before escape analysis, // because variables captured by value do not escape. -- 2.48.1