Skip to content

Commit

Permalink
Fix issue with custom types shadowing basic types (vektra#163)
Browse files Browse the repository at this point in the history
When a custom type has a name that can shadow an in-built type, append
MoqParam to the name. Example: var name stringMoqParam for null.String.
  • Loading branch information
dedalusj authored and LandonTClipp committed Nov 20, 2023
1 parent c40b013 commit 2b7cb51
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/registry/var.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ func varName(vr *types.Var, suffix string) string {
switch name {
case "mock", "callInfo", "break", "default", "func", "interface", "select", "case", "defer", "go", "map", "struct",
"chan", "else", "goto", "package", "switch", "const", "fallthrough", "if", "range", "type", "continue", "for",
"import", "return", "var":
"import", "return", "var",
// avoid shadowing basic types
"string", "bool", "byte", "rune", "uintptr",
"int", "int8", "int16", "int32", "int64",
"uint", "uint8", "uint16", "uint32", "uint64",
"float32", "float64", "complex64", "complex128":
name += "MoqParam"
}

Expand Down

0 comments on commit 2b7cb51

Please sign in to comment.