Diagnostic codes

Every compiler diagnostic carries a four-character prefix plus a four-digit number: GP for the parser / lexer, GR for name resolution, GT for the type checker, GM for match exhaustiveness, GL for lint framework, GK for the package manager. Use gos explain <code> for the interactive version. This page is auto-generated from the catalogue in xtask/src/main.rs; hand edits are overwritten by cargo xtask docs-diagnostics.

Code Phase Title
GP0001 Parser unexpected token
GP0002 Parser unexpected end of input
GP0003 Parser unterminated delimiter
GP0004 Parser chained comparison without parentheses
GR0001 Resolve unresolved name
GR0002 Resolve wrong namespace
GR0003 Resolve duplicate item
GR0004 Resolve duplicate import
GT0001 Types type mismatch
GT0002 Types unresolved method
GT0003 Types unresolved operator
GT0004 Match exhaustiveness non-exhaustive match
GT0005 Types non-primitive cast
GK0001 Package manager manifest parse error

GP0001

Parser — unexpected token

The parser saw a token where it expected a different one. Check for missing punctuation, an unmatched delimiter, or an out-of-place keyword.

GP0002

Parser — unexpected end of input

The parser reached end-of-file in the middle of a construct. Finish the expression, statement, or item — or remove it.

GP0003

Parser — unterminated delimiter

A balanced construct (block, tuple, array, string literal) was left unterminated. Add the matching closing delimiter.

GP0004

Parser — chained comparison without parentheses

Comparison operators like == / != / < are not associative. Parenthesise the operands: (a == b) && (b == c).

GR0001

Resolve — unresolved name

A name used in source could not be resolved to a declaration. Check the spelling, whether a use brings the name into scope, and whether the item is visible at this location.

GR0002

Resolve — wrong namespace

A name was resolved to the wrong namespace (value vs. type). Check the declaration and the spelling.

GR0003

Resolve — duplicate item

Two items in the same module share a name. Rename one of them or move it into a distinct mod.

GR0004

Resolve — duplicate import

The same path was imported twice in the same use list. Drop the duplicate.

GT0001

Types — type mismatch

The type checker could not reconcile two types it expected to match. The primary label shows the location of the mismatch; the note: line names the conflicting types.

GT0002

Types — unresolved method

The type checker could not find a method with the supplied name on the receiver type. Check for a typo, a missing use, or a trait impl that lives in an unreachable module.

GT0003

Types — unresolved operator

The operator is not defined for the operand types. Check the operand types and use the correct operator.

GT0004

Match exhaustiveness — non-exhaustive match

A match expression does not cover every possible value. Add an arm for the pattern(s) listed under help:.

GT0005

Types — non-primitive cast

The as cast is restricted to a whitelist: numeric ↔ numeric, bool/char → integer, u8char, and same-type no-ops. Struct / enum / String sources are rejected. Use a conversion method when you need serialisation; as does not run code.

GK0001

Package manager — manifest parse error

The package manifest (gos.toml) could not be parsed. Check the TOML syntax and required fields.