1
0
mirror of https://github.com/golang/go synced 2024-11-23 01:20:02 -07:00
go/test/fixedbugs/issue4517a.go
Russ Cox 3aed92f811 cmd/gc: add diagnostic for var, type, const named init
Before this CL, defining the variable worked fine, but then when
the implicit package-level init func was created, that caused a
name collision and a confusing error about the redeclaration.

Also add a test for issue 3705 (func init() needs body).

Fixes #4517.

R=ken2
CC=golang-dev
https://golang.org/cl/7008045
2012-12-22 17:23:33 -05:00

10 lines
246 B
Go

// errorcheck
// Copyright 2012 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.
package p
var init = 1 // ERROR "cannot declare init - must be func"