mirror of
https://github.com/golang/go
synced 2024-11-02 11:50:30 +00:00
cmd/compile: don't crash when reporting some syntax errors
Fixes #19667. Change-Id: Iaa71e2020af123c1bd3ac25e0b760956688e8bdf Reviewed-on: https://go-review.googlesource.com/38458 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
2ae79d0711
commit
b5e1ae46ad
2 changed files with 16 additions and 0 deletions
|
@ -341,6 +341,9 @@ func (p *printer) printNode(n Node) {
|
|||
|
||||
func (p *printer) printRawNode(n Node) {
|
||||
switch n := n.(type) {
|
||||
case nil:
|
||||
// we should not reach here but don't crash
|
||||
|
||||
// expressions and types
|
||||
case *Name:
|
||||
p.print(_Name, n.Value) // _Name requires actual value following immediately
|
||||
|
|
13
test/fixedbugs/issue19667.go
Normal file
13
test/fixedbugs/issue19667.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
// 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.
|
||||
|
||||
// Make sure we don't crash when reporting this error.
|
||||
|
||||
package p
|
||||
|
||||
func f() {
|
||||
if err := http.ListenAndServe(
|
||||
} // ERROR "unexpected }, expecting expression"
|
Loading…
Reference in a new issue