Skip to content

gccgo: correct channel conversion is not accepted #4110

@griesemer

Description

@griesemer
package p
var c chan int
var x int = <-chan int(c)

produces a compiler error:

x.go:3:23: error: expected ';' or newline after top level declaration
x.go:3:5: error: incompatible type in initialization

but it should be interpreted as:

package p
var c chan int
var x int = <-(chan int)(c)

According to the spec, <-chan int(c) is not a conversion (
http://tip.golang.org/ref/spec#Conversions ); this is even true under consideration of
issue #4109 (documentation error in the spec).

The gc compiler accepts this code.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions