From: Robert Griesemer Date: Mon, 13 Feb 2017 17:22:46 +0000 (-0800) Subject: cmd/compile/internal/parser: don't crash after unexpected token X-Git-Tag: go1.9beta1~1599 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ee2f5fafd88b5ce1404fa40e3645a409e9630897;p=gostls13.git cmd/compile/internal/parser: don't crash after unexpected token Added missing nil-check. We will get rid of the gcCompat corrections shortly but it's still worthwhile having the new test case added. Fixes #19056. Change-Id: I35bd938a4d789058da15724e34c05e5e631ecad0 Reviewed-on: https://go-review.googlesource.com/36908 Run-TryBot: Robert Griesemer TryBot-Result: Gobot Gobot Reviewed-by: Matthew Dempsky --- diff --git a/src/cmd/compile/internal/syntax/parser.go b/src/cmd/compile/internal/syntax/parser.go index a11be9717c..79d6c8c14d 100644 --- a/src/cmd/compile/internal/syntax/parser.go +++ b/src/cmd/compile/internal/syntax/parser.go @@ -799,7 +799,7 @@ loop: p.syntax_error("expecting name or (") p.advance(_Semi, _Rparen) } - if gcCompat { + if gcCompat && x != nil { x.init(p) } diff --git a/test/fixedbugs/issue19056.go b/test/fixedbugs/issue19056.go new file mode 100644 index 0000000000..e4e8d07905 --- /dev/null +++ b/test/fixedbugs/issue19056.go @@ -0,0 +1,9 @@ +// errorcheck + +// Copyright 2017 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. + +package p + +var _ = ... . // ERROR "unexpected ..."