Skip to content

T001 -- Type and Semantic Error

T001 is the umbrella code for the type checker: the program is structurally valid but does not type-check. The message names the specific problem.

Common messages

Return type mismatch:

fn f() -> Int {
  return "s";
}
error[T001]: 2:3: return type mismatch: expected Int, found Str

Argument type mismatch:

error[T001]: 3:3: argument 1 type mismatch: expected Int, found Str

Undefined variable:

error[T001]: 2:11: undefined variable 'missing'

Annotated type does not match the value:

error[T001]: 2:3: type mismatch in let: annotated Nope, found Int

Conditions must be Bool:

error[T001]: 2:6: if condition must be Bool, found Int

Logical negation requires Bool:

error[T001]: 2:11: cannot logically negate type Int

Calling something that is not callable:

error[T001]: 3:3: cannot call 'nope' on this expression

Fix

  • Match the declared return type, or cast with as where the conversion is explicit.
  • Check the argument order and types at the call site.
  • Fix spelling of names, then check imports (use ...;).
  • Conditions in if / while must be Bool; comparisons already are.

Notes

  • --diagnostics=json reports the same code per diagnostic, which tooling can map back to this page.
  • T001 is one code with many messages; the message text is the authoritative description of what failed.