$$ = closurebody($3);
fixlbrace($2);
}
-
+| fnlitdcl error
+ {
+ $$ = closurebody(nil);
+ }
/*
* lists of things
resumetypecopy();
resumecheckwidth();
- for(l=xtop; l; l=l->next)
+ for(l=xtop; l; l=l->next) {
if(l->n->op == ODCLFUNC || l->n->op == OCLOSURE) {
curfn = l->n;
saveerrors();
if(nerrors != 0)
l->n->nbody = nil; // type errors; do not compile
}
+ }
+
curfn = nil;
+
+ if(nsavederrors+nerrors)
+ errorexit();
for(l=xtop; l; l=l->next)
if(l->n->op == ODCLFUNC)
case OPACK:
break;
default:
+ lineno = lno;
return n;
}
}
if(n->typecheck == 2) {
yyerror("typechecking loop");
+ lineno = lno;
return n;
}
n->typecheck = 2;
- lno = setlineno(n);
if(n->sym) {
if(n->op == ONAME && n->etype != 0 && !(top & Ecall)) {
yyerror("use of builtin %S not in function call", n->sym);
L1: // ERROR "statement"
default:
// correct since no semicolon is required before a '}'
- L2: // ERROR "not used"
+ goto L2
+ L2:
}
}
package ddd
func Sum() int
- for i := range []int{} { return i } // ERROR "return outside function|expected"
+ for i := range []int{} { return i } // ERROR "statement outside function|expected"
--- /dev/null
+// errchk $G $D/$F.go
+
+// Copyright 2011 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.
+
+// issue 2089 - internal compiler error
+
+package main
+
+import (
+ "io"
+ "os"
+)
+
+func echo(fd io.ReadWriterCloser) { // ERROR "undefined: io.ReadWriterCloser"
+ var buf [1024]byte
+ for {
+ n, err := fd.Read(buf)
+ if err != nil {
+ break
+ }
+ fd.Write(buf[0:n])
+ }
+}
+
+func main() {
+ fd, _ := os.Open("a.txt")
+ echo(fd)
+}
--- /dev/null
+// errchk $G $D/$F.go
+
+// Copyright 2011 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.
+
+// issue 1993.
+// error used to have last line number in file
+
+package main
+
+func bla1() bool {
+ return false
+}
+
+func bla5() bool {
+ _ = 1
+ false // ERROR "false not used"
+ _ = 2
+}
+
+func main() {
+ x := bla1()
+ _ = x
+}
--- /dev/null
+// errchk $G $D/$F.go
+
+// Copyright 2011 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.
+
+// issue 1979
+// used to get internal compiler error too
+
+package main
+
+import (
+ "http"
+ "io/ioutil"
+ "os"
+)
+
+func makeHandler(fn func(http.ResponseWriter, *http.Request, string)) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) // ERROR "syntax error"
+}
+
+type Page struct {
+ Title string
+ Body []byte
+}
+
--- /dev/null
+// errchk $G $D/$F.go
+
+// Copyright 2011 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.
+
+// issue 1910
+// error on wrong line
+
+package main
+
+import "container/list"
+
+type Painting struct {
+ fragments list.List // private
+}
+
+func (p Painting) Foo() {
+ for e := p.fragments; e.Front() != nil; e = e.Next() { // ERROR "unexported field"
+ }
+}
+
+// from comment 4 of issue 1910
+type Foo interface {
+ Run(a int) (a int) // ERROR "a redeclared"
+}