Fixes #17637.
Change-Id: I5af63b8277c0a0f9fef4880992bcb925ca088687
Reviewed-on: https://go-review.googlesource.com/32106
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
return
}
- // don't declare blank aliases
- if decl.Name.Value == "_" {
+ // handle special cases
+ switch decl.Name.Value {
+ case "_":
+ return // don't declare blank aliases
+ case "init":
+ yyerror("cannot declare init - must be non-alias function declaration")
return
}
package p
import (
+ "flag"
"fmt" // use at most once (to test "imported but not used" error)
"go/build"
. "go/build"
func sin => math.Sin
func sin1 => math.Pi // ERROR "math.Pi is not a function"
+// aliases may not be called init
+func init => flag.Parse // ERROR "cannot declare init"
+
// alias reference to a package marks package as used
func _ => fmt.Println
// re-exported aliases
const Pi => math.Pi
+
type Writer => io.Writer
+
var Def => build.Default
+
func Sin => math.Sin
// type aliases denote identical types