golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.28k stars 610 forks source link

Panic on array parsing if length is externally defined #561

Closed jmaeso closed 3 years ago

jmaeso commented 3 years ago

Actual behavior

generating code for the following interface makes the tool to panic.

(Note: math constant used just for convenience. Can be any other package-defined constant, not a hardcoded value)

type Fooer interface {
    Foo([math.MaxInt8]string)
}

Output: panic: interface conversion: ast.Expr is *ast.SelectorExpr, not *ast.BasicLit

Expected behavior

Generate a mocked struct with a method that takes a [127]string{} (or [math.MaxInt8]string{}) array

To Reproduce Steps to reproduce the behavior Explained in the "Actual behaviour" section

Additional Information

Triage Notes for the Maintainers

codyoss commented 3 years ago

Thanks for the report. It looks like more work needs to be done onto the changes that were made in #520. I think those changes assume that the const is defined locally. I would be willing to accept a PR for this issue.