Skip to content

cmd/compile: confusing error message "shift of type float64" #19963

@josharian

Description

@josharian

https://play.golang.org/p/UntLLbfSoY

package main

func main() {
	var b uint8
	var _ float64 = 1.5 * (1 << b)
}

generates the error message

main.go:5: invalid operation: 1 << b (shift of type float64)

But there's no shift of type float64. There's a shift of type uint8. The problem is that the result of that shift needs to be converted into a float64 before multiplying.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions