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

go/types: incorrect type recorded for comma-ok expression #6796

Closed
griesemer opened this issue Nov 20, 2013 · 1 comment
Closed

go/types: incorrect type recorded for comma-ok expression #6796

griesemer opened this issue Nov 20, 2013 · 1 comment

Comments

@griesemer
Copy link
Contributor

A parenthesized type assertion in a comma,ok context doesn't get a recorded comma-ok
type: it gets a scalar type and only the enclosing ParenExpr gets a tuple.

I've instrumented the record functions below so you can see it in the log.

cheers
alan


% cat c.go

package main 

func main() {
   var i interface{} 
   v, ok := (i.(*int))
   print(v, ok)
}

% ./ssadump c.go
recordTypeAndValue("<expr *ast.InterfaceType>", interface{})
recordTypeAndValue("i", interface{})
recordTypeAndValue("int", int)
recordTypeAndValue("*int", *int)
recordTypeAndValue("i.(*int)", *int)
recordTypeAndValue("(i.(*int))", *int)
recordCommaOkTypes("(i.(*int))", *int, bool)
recordTypeAndValue("print", invalid type)
recordTypeAndValue("v", *int)
recordTypeAndValue("ok", bool)
recordTypeAndValue("print", func(*int, bool))
recordTypeAndValue("print(v, ok)", ())
panic: interface conversion: types.Type is *types.Pointer, not *types.Tuple

code.google.com/p/go.tools/ssa.(*builder).exprN(0x7f8288597c8f, 0xc210021b40,
0x7f828871f838, 0xc210037cf0, 0x7f828871fa01, ...)
        /home/adonovan/go3/got/src/code.google.com/p/go.tools/ssa/builder.go:216 +0x857
...
@griesemer
Copy link
Contributor Author

Comment 1:

This issue was closed by revision golang/tools@ef434a1.

Status changed to Fixed.

@griesemer griesemer self-assigned this Nov 21, 2013
@golang golang locked and limited conversation to collaborators Jun 25, 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

2 participants