mirror of
https://github.com/golang/go
synced 2024-11-24 16:40:15 -07:00
c30b570468
With the recursive descent parser that gccgo uses, I think that it doesn't make sense to try to match a statement where a statement is not expected. If the construct is not a statement, you will just get bizarre error messages. topexpr.go:9:1: error: expected declaration topexpr.go:14:1: error: expected declaration topexpr.go:19:1: error: expected declaration R=rsc, r2 CC=golang-dev https://golang.org/cl/2175041
21 lines
514 B
Go
21 lines
514 B
Go
// errchk $G -e $D/$F.go
|
|
|
|
// Copyright 2010 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 main
|
|
|
|
fmt.Printf("hello") // ERROR "non-declaration statement outside function body|expected declaration"
|
|
|
|
func main() {
|
|
}
|
|
|
|
x++ // ERROR "non-declaration statement outside function body|expected declaration"
|
|
|
|
func init() {
|
|
}
|
|
|
|
x,y := 1, 2 // ERROR "non-declaration statement outside function body|expected declaration"
|
|
|