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

x, ok := <-c gives ok==false but x!=0 #401

Closed
gopherbot opened this issue Dec 9, 2009 · 2 comments
Closed

x, ok := <-c gives ok==false but x!=0 #401

gopherbot opened this issue Dec 9, 2009 · 2 comments

Comments

@gopherbot
Copy link
Contributor

by nigel.tao.gnome:

What steps will reproduce the problem?
---------------------------
package main

import (
    "fmt";
)

func main() {
    c := make(chan int);
    func(s string){}("abcdefg");
    x, ok := <-c;
    fmt.Printf("x is %v, ok is %v\n", x, ok);
}
---------------------------

What is the expected output? What do you see instead?
If ok is false, then I expect x to be the zero value (as per the last line
of http://golang.org/doc/go_spec.html#Communication_operators).

Instead:
$ ./6.out 
x is 7, ok is false

Note that 7 is the length of the string "abcdefg".


What is your $GOOS?  $GOARCH?
linux amd64


Which revision are you using?  (hg identify)
8cc3a6f7ad37 tip
@agl
Copy link
Contributor

agl commented Dec 9, 2009

Comment 1:

Labels changed: added compilerbug.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Dec 16, 2009

Comment 2:

This issue was closed by revision d16bc7a.

Status changed to Fixed.

Merged into issue #-.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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

3 participants