{"record":{"id":"bd926efff82ace0e","repo":"kataras/iris","slug":"func-s-input-arguments-should-have-the-same-type","errorCode":null,"errorMessage":"func's input arguments should have the same type: [%d] expected %s but got %s","messagePattern":"func's input arguments should have the same type: \\[(.+?)\\] expected (.+?) but got (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"macro/macro.go","lineNumber":216,"sourceCode":"\t\t\t\tval = v\n\t\t\tcase reflect.Bool:\n\t\t\t\tv, err := strconv.ParseBool(arg)\n\t\t\t\tpanicIfErr(i, err)\n\t\t\t\tval = v\n\t\t\tcase reflect.Slice:\n\t\t\t\tif len(arg) > 1 {\n\t\t\t\t\tif arg[0] == '[' && arg[len(arg)-1] == ']' {\n\t\t\t\t\t\t// it is a single argument but as slice.\n\t\t\t\t\t\tval = strings.Split(arg[1:len(arg)-1], \",\") // only string slices.\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tval = arg\n\t\t\t}\n\n\t\t\targValue := reflect.ValueOf(val)\n\t\t\tif expected, got := field.Kind(), argValue.Kind(); expected != got {\n\t\t\t\tpanic(fmt.Sprintf(\"func's input arguments should have the same type: [%d] expected %s but got %s\", i, expected, got))\n\t\t\t}\n\n\t\t\targValues = append(argValues, argValue)\n\t\t}\n\n\t\tevalFn := reflect.ValueOf(fn).Call(argValues)[0]\n\n\t\t// var evaluator EvaluatorFunc\n\t\t// // check for typed and not typed\n\t\t// if _v, ok := evalFn.(EvaluatorFunc); ok {\n\t\t// \tevaluator = _v\n\t\t// } else if _v, ok = evalFn.(func(string) bool); ok {\n\t\t// \tevaluator = _v\n\t\t// }\n\t\t// return func(paramValue any) bool {\n\t\t// \treturn evaluator(paramValue)\n\t\t// }\n\t\treturn evalFn","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/macro/macro.go#L198-L234","documentation":"For struct-based macro evaluators, each route argument's parsed value must match the corresponding struct field's Go kind; when kinds differ, registration/route validation panics with 'func's input arguments should have the same type: [%d] expected %s but got %s' (macro/macro.go:216).","triggerScenarios":"Passing a route argument that the evaluator parses into a value whose reflect.Kind differs from the struct field's kind — e.g. an int-typed field receiving a non-integer string, or a bool field given something other than true/false.","commonSituations":"Writing {n:number abc} (non-numeric text for a numeric field), or swapping argument order so a string lands in an int field in multi-argument evaluators.","solutions":["Ensure each argument value converts to the field's declared kind (int fields get integers, bool fields get true/false, etc.).","Check argument order against the struct's field order.","Change the struct field type to match the kind of values you pass in routes."],"exampleFix":"// before\napp.Get(\"/{n:number abc}\", h) // abc is not a number\n\n// after\napp.Get(\"/{n:number 42}\", h)","handlingStrategy":"validation","validationCode":"// Ensure each argument parses to the struct field's kind before route registration\nvar v interface{}\n_, err := fmt.Sscanf(arg, \"%d\", &v) // for int fields\nif err != nil {\n    log.Fatalf(\"argument %q does not match field kind\", arg)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Match argument literals to field kinds: numbers for int fields, true/false for bool.","Check argument order when the evaluator struct has mixed field types.","Cover every param-type usage in route tests."],"tags":["go","panic","type-mismatch","path-parameters"],"backgroundTag":"macro-argument-type-mismatch","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}