Commit 66e84713 authored by Rick Arnold's avatar Rick Arnold Committed by Rob Pike

cmd/gc: make missing package error fatal

No longer continue assuming package main.

Fixes #4776.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12677043
parent f2bc2755
...@@ -136,8 +136,7 @@ package: ...@@ -136,8 +136,7 @@ package:
{ {
prevlineno = lineno; prevlineno = lineno;
yyerror("package statement must be first"); yyerror("package statement must be first");
flusherrors(); errorexit();
mkpackage("main");
} }
| LPACKAGE sym ';' | LPACKAGE sym ';'
{ {
......
...@@ -2428,8 +2428,7 @@ yyreduce: ...@@ -2428,8 +2428,7 @@ yyreduce:
{ {
prevlineno = lineno; prevlineno = lineno;
yyerror("package statement must be first"); yyerror("package statement must be first");
flusherrors(); errorexit();
mkpackage("main");
} }
break; break;
......
// errorcheck
// Copyright 2013 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 4776: missing package declaration error should be fatal.
type MyInt int32 // ERROR "package statement must be first"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment