Skip to content

String literals fail when used in some conversion expressions #183

@gopherbot

Description

@gopherbot

by kirklin.mcdonald:

The following code fails to compile:

$ cat test3.go
package test

type T interface{}

var a = T("foo")
var b = (interface{})("bar")
kirk@mooquack ~/dev/gotest $ 6g test3.go
test3.go:5: illegal constant expression CONVIFACE string
test3.go:6: illegal constant expression CONVIFACE string

Given that the string type is assignment compatible with both T and 
interface{}, I would expect this code to compile. The code compiles 
successfully if string variables are used instead of string literals.

$ echo $GOOS $GOARCH
linux amd64
$ hg log -l1
changeset:   4040:703fb2c605af

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