Skip to content

Unable to resolve variable in switch statement when using pointers #1727

@nhooyr

Description

@nhooyr

Resolving seems to be broken for the following code:

package main import "net" func main() { clientList := make(map[int]struct{ message chan string conn *net.Conn }) message := "" for _, c := range clientList { select { case c.message <- message: // message (not c.message) resolves to clientList.message field definition instead of message := "" declaration default: (*c.conn).Close() // c is not resolved, change the code to c.conn.Close() and resolving will work } } }

Original report:
screen shot 2015-07-07 at 5 21 08 pm
screen shot 2015-07-07 at 5 21 21 pm

code is here: http://pastebin.com/KHnQ1zJM

First screenshot you can see that it doesn't resolve the conn properly, yes it compiles and functions perfectly. Second shot (line 102) same problem except now it resolves client as a type? Compiles and works perfectly. If I change it to c like the first SS it also gives the same error. Yes my code has naming issues atm, tore up between long vs short not sure but anyways this is a resolving issue for sure.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions