Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: spurious type mismatch error when assigning float64 to indexed string byte #8744

Closed
btracey opened this issue Sep 15, 2014 · 4 comments
Milestone

Comments

@btracey
Copy link
Contributor

btracey commented Sep 15, 2014

In the following program:

package main

func main() {
    var a float64
    var s string
    s[0] = a
}

The program reports:
prog.go:6: cannot assign to s[0]
prog.go:6: cannot use a (type float64) as type uint8 in assignment

There are two issues here. First, there are two errors when there could be one. This is
related to issue #6406. Second, the type mismatch is stated as float64 vs uint8, but it
should be float64 vs. byte. I'm not sure if these two issues are related, so I'm filing
them as one issue, but I can file a second issue if they are distinct.
@btracey
Copy link
Contributor Author

btracey commented Sep 15, 2014

Comment 1:

Sorry, by program I meant playground, and this is during 1.3.

@ianlancetaylor
Copy link
Contributor

Comment 2:

Labels changed: added repo-main, release-go1.5.

Status changed to Accepted.

@btracey
Copy link
Contributor Author

btracey commented Sep 15, 2014

Comment 3:

See issue #8745 for the float64 vs uint8

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@rsc rsc removed accepted labels Apr 14, 2015
@rsc rsc changed the title cmd/gc: spurious error when indexing into string, bad type mismatch report cmd/compile: spurious error when indexing into string, bad type mismatch report Jun 8, 2015
@rsc rsc changed the title cmd/compile: spurious error when indexing into string, bad type mismatch report cmd/compile: spurious type mismatch error when assigning float64 to indexed string byte Jun 29, 2015
@rsc
Copy link
Contributor

rsc commented Jun 29, 2015

The extra error does not bother me. There are two things wrong with the statement. Reporting both is okay.

@rsc rsc closed this as completed Jun 29, 2015
@golang golang locked and limited conversation to collaborators Jun 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants