mirror of
https://github.com/golang/go.git
synced 2025-05-06 08:03:03 +00:00
This makes a bunch of changes to package syntax to tweak line numbers for AST nodes. For example, short variable declaration statements are now associated with the location of the ":=" token, and function calls are associated with the location of the final ")" token. These help satisfy many unit tests that assume the old parser's behavior. Because many of these changes are questionable, they're guarded behind a new "gcCompat" const to make them easy to identify and revisit in the future. A handful of remaining tests are too difficult to make behave identically. These have been updated to execute with -newparser=0 and comments explaining why they need to be fixed. all.bash now passes with both the old and new parsers. Change-Id: Iab834b71ca8698d39269f261eb5c92a0d55a3bf4
21 lines
597 B
Go
21 lines
597 B
Go
// errorcheck -newparser=0
|
|
|
|
// Copyright 2015 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.
|
|
|
|
// Test an internal compiler error on ? symbol in declaration
|
|
// following an empty import.
|
|
|
|
// TODO(mdempsky): Update for new parser. New parser recovers more
|
|
// gracefully and doesn't trigger the "cannot declare name" error.
|
|
|
|
package a
|
|
import"" // ERROR "import path is empty"
|
|
var? // ERROR "illegal character U\+003F '\?'"
|
|
|
|
var x int // ERROR "unexpected var" "cannot declare name"
|
|
|
|
func main() {
|
|
}
|