File tree 2 files changed +13
-2
lines changed
src/cmd/compile/internal/gc
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -214,8 +214,12 @@ func (p *noder) aliasDecl(decl *syntax.AliasDecl) {
214
214
return
215
215
}
216
216
217
- // don't declare blank aliases
218
- if decl .Name .Value == "_" {
217
+ // handle special cases
218
+ switch decl .Name .Value {
219
+ case "_" :
220
+ return // don't declare blank aliases
221
+ case "init" :
222
+ yyerror ("cannot declare init - must be non-alias function declaration" )
219
223
return
220
224
}
221
225
Original file line number Diff line number Diff line change 9
9
package p
10
10
11
11
import (
12
+ "flag"
12
13
"fmt" // use at most once (to test "imported but not used" error)
13
14
"go/build"
14
15
. "go/build"
@@ -74,13 +75,19 @@ func _ => math.Sin
74
75
func sin = > math .Sin
75
76
func sin1 = > math .Pi // ERROR "math.Pi is not a function"
76
77
78
+ // aliases may not be called init
79
+ func init = > flag .Parse // ERROR "cannot declare init"
80
+
77
81
// alias reference to a package marks package as used
78
82
func _ = > fmt .Println
79
83
80
84
// re-exported aliases
81
85
const Pi = > math .Pi
86
+
82
87
type Writer = > io .Writer
88
+
83
89
var Def = > build .Default
90
+
84
91
func Sin = > math .Sin
85
92
86
93
// type aliases denote identical types
You can’t perform that action at this time.
0 commit comments