TP0200
Error: type mismatch
Messages
Section titled “Messages”expected <T>, found <S>(annotations, arguments, return values, assignments)operator '<op>' cannot be applied to <S> and <T>operator '<op>' cannot be applied to <S>cannot compare <S> and <T>'<f>' does not return a value'<f>' has no return type, so 'return' cannot have a valuemissing return value; '<f>' returns <T>'<x>' is not a functioncannot call <T>(a callee that isn’t a name)'<f>' is generic, so it cannot be used as a valuebuilt-in '<f>' cannot be used as a value, with helpwrap it in a lambda(M11)'<f>' has '*args' or '**kwargs', so it cannot be used as a value, with helpwrap it in a lambdacannot unpack <T> into arguments(M30)'<f>' yields, so it must return 'Iterator[T]'a generator can't return a valuecannot index <T>cannot slice <T>'len' takes a list, dict or str, found <T>, each with helpconvert it with 'list(…)' firstfor an iterator (M31)expected <T>, found lambdacannot sort <T>, with helppass a key, e.g. 'key=lambda x: ...'cannot sort by <K>(M11)tuple index must be an integer literalindex <i> out of range for <T>(a tuple)cannot unpack <T>cannot slice <T>(M12)integer literal is out of range'range' can only be used in a for loopcannot iterate over <T>'<T>' is inferred as both <A> and <B>'<T>' must be <A> or <B>, found <C>(type-argument inference and constraints;A, B or Cfor longer tuples)'<m>' is a module, not a value'as' converts py values; found <T>cannot convert to <T>cannot pass <T> to Python(§10)cannot match on <T>'<E>' is a type, not a value'<v>' is not a function(a variant without a payload)'is some' needs an optional, found <T>'is None' needs an optional, found <T>'is not None' needs an optional, found <T>'??' needs an optional on the left, found <T>'<m>' is a method; call it'<f>' is a field, not a methodcannot index <T>dict keys must be int, str, bool, tuples of those, or plain class instances, found <T>(for a dataclass, with helpa dataclass compares by value, so it cannot be a key; since M28 a class that isn’t hashable getsdict keys must be hashable, found <C>instead, §4.8)isinstance needs a class, found <T>'<C>' is not a class'<C>' is generic<T> can never be a <C>(isinstance,asand class patterns on unrelated classes)'<C>' is a class; write '<C>()'(a class pattern without parentheses) (M15)no overload of '<T>.<m>' takes (<A1>, <A2>)'<T>' is a static class(constructing it, or using it as a type)'<T>' cannot be constructed(an interface, abstract class or enum)<v> is out of range for <N>(a literal argument,<N>the .NET type’s name, such asInt32)'<T>.<m>' returned null(TypeError, at run time)'<C>' is not an exception class(a .NET class not deriving fromSystem.Exception)cannot bind both Taipan and .NET exceptions, with helpwrite separate clauses(M21)'<n>' is a .NET namespace, not a valuea .NET exception can't have a cause, with helppass it to the constructor as the inner exception(for the cause)'<E>' is an event; use '+=' or '-='<S> can never be a <T>and'<T>' is genericfor .NET types (isinstance,asand class patterns) (M43)'<T>' does not satisfy '<P>': it has no field '<f>''<T>' does not satisfy '<P>': '<f>' must be '<f>: <F>''<T>' does not derive from '<C>'<P> can never be a <C>'<f>' cannot be used as a value, with helpwrap it in a lambda'is' compares identity, which <T> doesn't have, with helpuse '=='isinstance on py takes int, float, str, bool, list, dict, tuple or a Python class, found <T>(M40)'from' needs an exception or None, found <T>(with helpwrite '<C>(…)'for a class name) (M41)'yield' needs a value: '<f>' yields <Y>a generator declared '<T>' can't return a value, with helpdeclare it 'Generator[Y, S, R]''<f>' can end without returning a <R>'yield from' over <T> gives no value'<f>' is an async generator, so it must return 'AsyncIterator[T]'an async generator can't return a valuecannot iterate over <T> with 'async for'(helpuse 'for'for a plain iterable)<T> is not an async context manager(helpuse 'with'for a plain context manager,define '__aenter__' and '__aexit__'otherwise), and withwith, helpuse 'async with'object has no attribute '<a>', with helpconvert it with 'as'(M42)expected Self, found <C>a class attribute can't use '<T>''<m>' is generic, so it cannot be used as a valuefor a generic class’s static or class method without type arguments (M39)<T> can't be None<T> cannot match a mapping patternmapping keys must be int, str or bool, found <K>alternatives bind different names: '<x>' is not bound in every one'<x>' is <A> in one alternative and <B> in another(M38)every arm of this 'match' raises, with helpuse a 'match' statement(M19)this arm gives no value, with helpend it with an expression<T> cannot match a tuple pattern<T> cannot match a list pattern'*<x>' would hold <A> and <B>(a starred name in a tuple) (M29)set elements must be hashable, found <T>sum() takes numbers, found <T>, with helpuse ''.join(…)forstr'any' takes bools, found <T>(and'all'), with helptest each value, as in any(x > 0 for x in xs)'min' needs values that can be ordered, found <T>(and'max'), with helppass a key, e.g. 'key=lambda x: ...'an int can't be raised to a negative power, with helpuse a float base, as in 2.0 ** -1(M35)<T> is not a context manager, with helpdefine '__enter__' and '__exit__'invalid mode '<m>', with help naming a deferred mode'open' needs a literal mode(andencoding,newline)unknown encoding '<e>'newline must be None or '''type[…]' needs a class, found <T>(M37)format spec '<spec>' isn't valid for <T>, with help naming the part that isn’tformat specs apply to int, float and str, found <T>(M26)'<A>' is a type alias, not a value, with helpuse '<N>'when it names a class or enum (M18)cannot raise <T>(with helpwrite '<C>(…)'for a class name)'<C>' is not an exception class'PythonError' cannot be constructed(and'DotNetError', M21) (M16)'<T>' does not satisfy '<P>': it has no method '<m>''<T>' does not satisfy '<P>': '<m>' must be 'def <m>(self, …) -> <R>'(the protocol’s signature withSelfreplaced;-> <R>left out when it returns nothing), at a call’s callee or a declared protocol, with(declared by '<B>')after'<P>'for an inherited declaration'...' can only be the body of a protocol method'<m>' cannot be called directly, with helpuse '<'(M17)'super()' can only be used as 'super().<method>(…)''super()' can only be used in a method'<C>' has no base class'__init__' cannot be called directly'__init__' cannot have a return type(M15)'<m>' cannot be called directly, with helpuse '<form>'(a special method, as M17’s__lt__)dict keys must be hashable, found <C>, with help as §4.8 sayscannot hash <T>'+' on <A> and <B> is ambiguous: '<C>.__add__' would run when it fits'<p>' is a property; read it from an instance'<m>' needs an instance of '<C>''cls' can only be called, or used to reach static and class methods and class attributes'ClassVar' can only annotate a class attribute'<B>.<m>' is abstract(M28)
Example
Section titled “Example”From the golden case tests/cases/m26/tp0200_everyday.tpn:
# isinstance and zip mistakes (SPEC §6).class A: pass
class B: pass
let a = A()print(isinstance(a, (A, B)))print(zip([1, 2]))The compiler reports:
tp0200_everyday.tpn:9:25: error TP0200: A can never be a Btp0200_everyday.tpn:10:7: error TP0209: 'zip' takes 2 or more arguments, found 1The specification lists every code.
© 2026 Discover Edge, LLC · Taipan is released under the MIT License.