From 2f4a14d8d7c82eadac02a2de23445d46342b224c Mon Sep 17 00:00:00 2001 From: dedalusj Date: Sat, 18 Dec 2021 14:26:01 +1100 Subject: [PATCH] Fix issue with custom types shadowing basic types (#163) 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. --- internal/registry/var.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/registry/var.go b/internal/registry/var.go index abb0d53be..081a17c75 100644 --- a/internal/registry/var.go +++ b/internal/registry/var.go @@ -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" }