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

Inconsistent behavior of := #514

Closed
gopherbot opened this issue Jan 11, 2010 · 2 comments
Closed

Inconsistent behavior of := #514

gopherbot opened this issue Jan 11, 2010 · 2 comments

Comments

@gopherbot
Copy link
Contributor

by quaggy:

What steps will reproduce the problem?
1. Compile bug.go
2. Run bug

What is the expected output?
EOF EOF

What do you see instead?
<nil> EOF

What is your $GOOS?  $GOARCH?
darwin and amd64

Which revision are you using?
7d7941a84d46 tip

Please provide any additional information below.

f() always returns nil. g() always returns the err from h(). Both functions
should behave the same way.

func f() (err os.Error) {
    if n, err := h(); err == nil {
        fmt.Println(n)
    }   
    return
}

func g() (err os.Error) {
    n, err := h() 
    if err == nil {
        fmt.Println(n)
    }   
    return
}

Attachments:

  1. bug.go (332 bytes)
@peterGo
Copy link
Contributor

peterGo commented Jan 11, 2010

Comment 1:

Isn't this a duplicate of issue #377: := can shadow named return variables (and others)

@rsc
Copy link
Contributor

rsc commented Jan 11, 2010

Comment 2:

Status changed to Duplicate.

Merged into issue #377.

@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