Skip to content

go/types: randomly ordered 'declared but not used' errors #22525

@rsc

Description

@rsc
$ cat x.go
package p

func f() {
	var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z int
}
$ gotype x.go
x.go:4:54: q declared but not used
x.go:4:6: a declared but not used
x.go:4:9: b declared but not used
x.go:4:18: e declared but not used
x.go:4:21: f declared but not used
x.go:4:42: m declared but not used
x.go:4:15: d declared but not used
x.go:4:36: k declared but not used
x.go:4:51: p declared but not used
x.go:4:57: r declared but not used
$ gotype x.go
x.go:4:6: a declared but not used
x.go:4:15: d declared but not used
x.go:4:30: i declared but not used
x.go:4:42: m declared but not used
x.go:4:48: o declared but not used
x.go:4:51: p declared but not used
x.go:4:66: u declared but not used
x.go:4:69: v declared but not used
x.go:4:75: x declared but not used
x.go:4:81: z declared but not used
$ gotype x.go
x.go:4:21: f declared but not used
x.go:4:30: i declared but not used
x.go:4:51: p declared but not used
x.go:4:63: t declared but not used
x.go:4:72: w declared but not used
x.go:4:75: x declared but not used
x.go:4:69: v declared but not used
x.go:4:78: y declared but not used
x.go:4:6: a declared but not used
x.go:4:9: b declared but not used
$ 

The reordering happens for single declarations on different lines too. Looks like there is a sort needed somewhere after a map iteration.

(This issue and #22524 matter for Go 1.10 because vet is going to start reporting errors from go/types.)

/cc @griesemer

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions