mirror of
https://github.com/golang/go
synced 2024-11-21 20:14:52 -07:00
gc: insert semicolon at EOF if needed
R=ken2, gri CC=golang-dev https://golang.org/cl/2208053
This commit is contained in:
parent
b233ac8f18
commit
ec13ed1fce
@ -1247,13 +1247,8 @@ yylex(void)
|
|||||||
lx = _yylex();
|
lx = _yylex();
|
||||||
|
|
||||||
if(curio.nlsemi && lx == EOF) {
|
if(curio.nlsemi && lx == EOF) {
|
||||||
// if the nlsemi bit is set, we'd be willing to
|
// Treat EOF as "end of line" for the purposes
|
||||||
// insert a ; if we saw a \n, but we didn't.
|
// of inserting a semicolon.
|
||||||
// that means the final \n is missing.
|
|
||||||
// complain here, because we can give a
|
|
||||||
// good message. the syntax error we'd get
|
|
||||||
// otherwise is inscrutable.
|
|
||||||
yyerror("missing newline at end of file");
|
|
||||||
lx = ';';
|
lx = ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
test/eof.go
Normal file
9
test/eof.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// $G $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.
|
||||||
|
|
||||||
|
// No newline at the end of this file.
|
||||||
|
|
||||||
|
package main
|
Loading…
Reference in New Issue
Block a user