Skip to content

cmd/compile: missing "out of bounds" error slicing [0]T #20749

@josharian

Description

@josharian
package p

func f() {
	var b [0]struct{}
	_ = b[2:]
}

gotype says:

x.go:5:8: index 2 (constant of type int) is out of bounds

cmd/compile gives no error. If you change b's type to [1]struct{}, the error from cmd/compile is:

x.go:5: invalid slice index 2 (out of bounds for 1-element array)

Reproduces with (at least) 1.7 and 1.8 and 1.9beta1.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions