Skip to content

TP0209

Error: wrong number of arguments

  • '<S>' takes <n> type arguments, found <m> (type argument when n is 1) (since M43 also for generic .NET types, and '<T>.<m>' takes <n> type arguments, found <k> for a .NET method)
  • '<v>' has <n> fields, found <m> bindings (variant and dataclass patterns; field / binding when the count is 1)
  • '<C>' is not a dataclass, so its fields can only be bound by name
  • field '<f>' is given more than once (class patterns, M15)
  • <T> has <n> elements, found <m> names (unpacking)
  • a tuple needs at least two elements (M12)
  • <T> has <n> elements, found <m> patterns (a tuple pattern, M29)
  • <T> has <n> elements, found at least <m> patterns (a tuple pattern with *, M38)
  • '<f>' takes <n> arguments, found <m> (argument when n is 1; 1 or 2 arguments for range; <a> to <b> arguments for a function with defaults, M14; 2 or more arguments for zip, M26; function takes … when the callee isn’t a name)
  • missing argument '<x>' (M14)
  • missing field '<f>' in '<S>'
  • field '<f>' is given more than once
  • argument '<k>' is given more than once
  • '<f>' takes <n> positional arguments, found <m>
  • missing keyword-only argument '<x>'
  • '*<e>' can only fill '*<args>'
  • '<f>' has no '*args' for '*<e>'
  • '<f>' has no '**kwargs' for '**<e>'
  • '**<e>' can't fill '<x>' (M30)
  • expected a lambda with <n> parameters, found <m> (parameter when n is 1)
  • 'Callable' takes a parameter list and a result type

From the golden case tests/cases/m38/tp0209_star.tpn:

tp0209_star.tpn
def f(t: tuple[int, int]) -> None:
match t:
(a, b, *c, d):
pass
_:
pass

The compiler reports:

tp0209_star.tpn:3:9: error TP0209: tuple[int, int] has 2 elements, found at least 3 patterns

The specification lists every code.