Skip to content

Diagnostics

The compiler reports problems as diagnostics, each with a code. Every code has a page with its messages and a program that gives it.

Format:

<file>:<line>:<col>: error TP<code>: <message>
help: <optional hint>
  • Diagnostics are written to stderr.

  • Lines and columns are 1-based. Columns count Unicode code points.

  • Each compiler stage runs only if the stages before it reported no errors: lexing (§1), then parsing (§2), then type checking. This keeps one mistake from cascading into spurious errors in later stages.

  • <file> is the source path exactly as given on the command line.

  • Warnings (TP0300, TP0301, TP0302 and TP0303) print as <file>:<line>:<col>: warning TP<code>: <message>. They don’t stop compilation or change the exit code. They’re printed with the type checker’s errors, before the program runs.

Exit codes:

  • 0 success
  • 1 compile error
  • 2 usage or I/O error (bad arguments, file not found)
  • 101 runtime panic
Code Kind Meaning
TP0001 error tab in indentation
TP0002 error dedent doesn’t match any outer indentation level
TP0003 error unterminated string
TP0004 error invalid character
TP0005 error invalid escape sequence
TP0006 error invalid f-string
TP0007 error invalid number literal
TP0100 error syntax error: expected X, found Y (including 'yield' needs a value, M31, until M42 allowed a bare yield)
TP0200 error type mismatch
TP0201 error undefined name
TP0202 error cannot assign to let binding
TP0203 error optional used without narrowing (expected T, got T?)
TP0204 error non-exhaustive match (missing: …)
TP0205 error condition must be bool
TP0206 error cannot infer type of empty collection
TP0207 error shadowing an outer binding
TP0208 error not all paths return a value
TP0209 error wrong number of arguments
TP0210 error unknown field or method
TP0211 error function references a top-level variable
TP0212 error chained comparison not supported
TP0213 error nested optional
TP0214 error duplicate definition
TP0215 error break/continue outside loop, return outside function, a bare raise outside except, return/break/continue in finally, or a misplaced yield or await
TP0216 error ambiguous enum variant; qualify it
TP0217 error const initializer is not a constant expression
TP0218 error keyword argument not accepted
TP0219 error generic instantiation too deep (polymorphic recursion)
TP0220 error invalid type parameter constraint or bound
TP0221 error module not found
TP0222 error top-level statement in an imported module, or in a library’s main file or an extension module
TP0223 error nested function with type parameters
TP0224 error invalid decorator
TP0225 error invalid class definition
TP0226 error object used before it is fully initialized
TP0227 error missing or unneeded @override
TP0228 error incompatible override
TP0229 error protocol used as a type
TP0230 error recursive type alias
TP0231 error .NET member or type that Taipan can’t use
TP0232 error ambiguous .NET overload
TP0233 error can’t be used in a native program
TP0234 error abstract class instantiated
TP0235 error awaitable never awaited
TPN001 error an SDK project’s main file is missing
TPN002 error an SDK project’s taipan.json lists references or packages
TP0300 warning warning: unreachable code (a statement, match arm or except clause)
TP0301 warning warning: broad except clause discards the exception
TP0302 warning warning: a library’s or extension module’s definition can’t be exported
TP0303 warning warning: a test_ function that can’t be run as a test