kataras/iris · error

func's input arguments should have the same type: [%d] expec

Error message

func's input arguments should have the same type: [%d] expected %s but got %s

What it means

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).

Source

Thrown at macro/macro.go:216

				val = v
			case reflect.Bool:
				v, err := strconv.ParseBool(arg)
				panicIfErr(i, err)
				val = v
			case reflect.Slice:
				if len(arg) > 1 {
					if arg[0] == '[' && arg[len(arg)-1] == ']' {
						// it is a single argument but as slice.
						val = strings.Split(arg[1:len(arg)-1], ",") // only string slices.
					}
				}
			default:
				val = arg
			}

			argValue := reflect.ValueOf(val)
			if expected, got := field.Kind(), argValue.Kind(); expected != got {
				panic(fmt.Sprintf("func's input arguments should have the same type: [%d] expected %s but got %s", i, expected, got))
			}

			argValues = append(argValues, argValue)
		}

		evalFn := reflect.ValueOf(fn).Call(argValues)[0]

		// var evaluator EvaluatorFunc
		// // check for typed and not typed
		// if _v, ok := evalFn.(EvaluatorFunc); ok {
		// 	evaluator = _v
		// } else if _v, ok = evalFn.(func(string) bool); ok {
		// 	evaluator = _v
		// }
		// return func(paramValue any) bool {
		// 	return evaluator(paramValue)
		// }
		return evalFn

View on GitHub (pinned to 7bedaf55a0)

Solutions

  1. Ensure each argument value converts to the field's declared kind (int fields get integers, bool fields get true/false, etc.).
  2. Check argument order against the struct's field order.
  3. Change the struct field type to match the kind of values you pass in routes.

Example fix

// before
app.Get("/{n:number abc}", h) // abc is not a number

// after
app.Get("/{n:number 42}", h)
Defensive patterns

Strategy: validation

Validate before calling

// Ensure each argument parses to the struct field's kind before route registration
var v interface{}
_, err := fmt.Sscanf(arg, "%d", &v) // for int fields
if err != nil {
    log.Fatalf("argument %q does not match field kind", arg)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30). Data as JSON: /api/errors/bd926efff82ace0e. Report an issue: GitHub.