提交 5b1beef9 编写于 作者: chai2010's avatar chai2010

凹禁止 package 语法, 仅作为一个保留关键字

上级 fff4d8c9
......@@ -2583,6 +2583,9 @@ func (p *parser) parseFile() *ast.File {
pos := p.pos
ident := &ast.Ident{}
if p.tok == token.PACKAGE {
if strings.HasSuffix(p.file.Name(), ".wz") && !strings.HasSuffix(p.file.Name(), ".go.wz") {
p.error(p.pos, "expected declaration, found package")
}
p.next()
// Go spec: The package clause is not a declaration;
// the package name does not appear in any scope.
......
......@@ -2493,6 +2493,9 @@ func (p *parser) parseFile() *ast.File {
pos := p.pos
ident := &ast.Ident{}
if p.tok == token.PACKAGE {
if strings.HasSuffix(p.file.Name(), ".wa") && !strings.HasSuffix(p.file.Name(), ".go.wa") {
p.error(p.pos, "expected declaration, found package")
}
p.next()
// Go spec: The package clause is not a declaration;
// the package name does not appear in any scope.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册