Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Panic on generating mock for interface with method returing array with const as size #294

Closed
jkmar opened this issue May 15, 2019 · 0 comments · Fixed by #520
Closed

Panic on generating mock for interface with method returing array with const as size #294

jkmar opened this issue May 15, 2019 · 0 comments · Fixed by #520

Comments

@jkmar
Copy link

jkmar commented May 15, 2019

I have the following file:

package main

const C = 2

type I interface{
    F() [C]int
}

when I'm trying to generate mock for the I interface, I'm getting a panic from mockgen:

$ mockgen -source=test.go
panic: interface conversion: ast.Expr is *ast.Ident, not *ast.BasicLit

goroutine 1 [running]:
main.(*fileParser).parseType(0xc00014fcc8, 0xc000145a90, 0xb, 0x782660, 0xc0000e8630, 0x0, 0x0, 0x3e, 0x8)
        /home/jakub/go/src/github.com/golang/mock/mockgen/parse.go:357 +0x12a9
main.(*fileParser).parseFieldList(0xc00014fcc8, 0xc000145a90, 0xb, 0xc0001a6090, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, ...)
        /home/jakub/go/src/github.com/golang/mock/mockgen/parse.go:333 +0x224
main.(*fileParser).parseFunc(0xc00014fcc8, 0xc000145a90, 0xb, 0xc0000ee340, 0xc0001b0180, 0xc00014f8a0, 0x40b5d9, 0xc0000ec380, 0xc00014f8b8, 0x40b5d9, ...)
        /home/jakub/go/src/github.com/golang/mock/mockgen/parse.go:310 +0x2c9
main.(*fileParser).parseInterface(0xc00014fcc8, 0x953ee9, 0x1, 0xc000145a90, 0xb, 0xc0000ee360, 0xc00014fa98, 0x405fd8, 0x6d9d80)
        /home/jakub/go/src/github.com/golang/mock/mockgen/parse.go:234 +0x213
main.(*fileParser).parseFile(0xc00014fcc8, 0xc000145a90, 0xb, 0xc0000f4380, 0x0, 0x0, 0xc0000f4380)
        /home/jakub/go/src/github.com/golang/mock/mockgen/parse.go:182 +0x436
main.parseFile(0x7fff90dd11e0, 0x7, 0x1, 0x1, 0x0)
        /home/jakub/go/src/github.com/golang/mock/mockgen/parse.go:100 +0x7a7
main.main()
        /home/jakub/go/src/github.com/golang/mock/mockgen/mockgen.go:65 +0xa67

I'm using the latest version of mockgen - commit: d74b93584564161b2de771089ee697f07d8bd5b5

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants