Skip to content

type assertion fails on a function of the correct type when named return value used #749

@jimmyfrasche

Description

@jimmyfrasche
1. What is a short input program that triggers the error?
 
package main

func A() bool { return false }
func B() (_ bool) { return false }
func C() (ok bool) { return false }

var funcs = []interface{} {A, B, C}

func main() {
   for i, f := range funcs {
       println(i)
       _ = f.(func()bool)
   }
}

2. What is the full compiler output?

0
1
2
panic: interface conversion: interface is func() (bool), not func() bool
*stack trace omitted*

3. What version of the compiler are you using?  (Run it with the -V flag.)
8g version 5289 release.2010-04-13 release

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions