Skip to content

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
GP0005 Parser chained range operator
GP0006 Parser struct literal in scrutinee
GP0007 Parser pipe right-hand side not callable
GP0008 Parser assignment outside statement position
GP0009 Parser expected integer literal
GP0010 Parser expected string literal
GP0011 Parser invalid tuple index
GP0012 Parser malformed label
GP0013 Parser malformed attribute
GP0014 Parser malformed use declaration
GP0015 Parser unexpected construct
GP0016 Parser reserved extern keyword
GP0017 Parser parser recursion limit
GP0018 Lexer malformed token
GP0019 Parser statement outside entry file
GP0020 Parser mixed entry forms
GP0021 Parser malformed format placeholder
GP0022 Parser unserializable derived field
GP0023 Parser format argument count mismatch
GP0024 Parser non-literal format template
GP0025 Parser piped format value has no placeholder
GP0026 Parser inclusive range missing upper bound
GP0027 Parser invalid pipe placeholder
GP0028 Parser range used as pipe placeholder
GP0029 Parser match arm missing arrow
GP0030 Parser match arm missing body
GP0031 Parser match arm missing separator
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
GT0044 Types generic return type not inferred
GT0045 Types question mark not supported here
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).

GP0005

Parser - chained range operator

Range operators (.., ..=) are not associative. Parenthesise the operands: (a..b)..c.

GP0006

Parser - struct literal in scrutinee

A braced struct literal in the scrutinee of if/while/match is ambiguous with the block. Wrap the literal in (...).

GP0007

Parser - pipe right-hand side not callable

The right-hand side of |> must be a callable: a function reference, a method call, or a closure.

GP0008

Parser - assignment outside statement position

Assignment (=, +=, …) only appears at statement position. If you need an expression, return the right-hand side directly.

GP0009

Parser - expected integer literal

An integer literal is required at this position.

GP0010

Parser - expected string literal

A string literal is required at this position.

GP0011

Parser - invalid tuple index

A tuple index must be a plain decimal integer (p.0, p.1). Hex, binary, or octal indices are not accepted.

GP0012

Parser - malformed label

A label identifier is required after the leading '.

GP0013

Parser - malformed attribute

An attribute is malformed. Accepted forms are #[attr], #[attr(args)], and #[attr = value].

GP0014

Parser - malformed use declaration

A use declaration could not be parsed. Check the path for stray punctuation or an unfinished brace list.

GP0015

Parser - unexpected construct

Two consecutive tokens formed something the parser does not recognise.

GP0016

Parser - reserved extern keyword

The extern keyword is reserved but has no source-level item form. Gossamer's FFI surface is the [rust-bindings] section of project.toml plus the gossamer-binding crate.

GP0017

Parser - parser recursion limit

An expression exceeded the parser's nesting limit. Split it into smaller helpers.

GP0018

Lexer - malformed token

The lexer rejected a malformed string, comment, escape, or token spelling.

GP0019

Parser - statement outside entry file

Executable statements belong in the entry file or inside a function, not in a module body.

GP0020

Parser - mixed entry forms

An entry file cannot combine bare top-level statements with an explicit fn main.

GP0021

Parser - malformed format placeholder

A format placeholder must be a binding name, format specification, or positional placeholder.

GP0022

Parser - unserializable derived field

Automatic serialization cannot be generated for a field with an unsupported type.

GP0023

Parser - format argument count mismatch

The number of positional arguments must equal the number of positional placeholders.

GP0024

Parser - non-literal format template

Format macros require a literal template so placeholders can be checked at compile time.

GP0025

Parser - piped format value has no placeholder

A value piped into a format macro needs an explicit positional placeholder.

GP0026

Parser - inclusive range missing upper bound

The inclusive range operator ..= requires an upper bound. Use .. for an open upper end.

GP0027

Parser - invalid pipe placeholder

A pipe placeholder must occur exactly once as a direct call argument.

GP0028

Parser - range used as pipe placeholder

The token .. starts a range. Use _ as the pipe placeholder.

GP0029

Parser - match arm missing arrow

Add => after the match arm pattern and optional guard.

GP0030

Parser - match arm missing body

Add the expression or block produced by the match arm.

GP0031

Parser - match arm missing separator

Separate same-line expression arms with a comma, or start the next arm on a new line.

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.

GT0044

Types - generic return type not inferred

A generic return payload cannot be inferred from call arguments alone. Add an explicit generic argument or assign the expression to an expected Result type.

GT0045

Types - question mark not supported here

The ? operator can only unwrap Result inside a Result-returning function or Option inside an Option-returning function.

GK0001

Package manager - manifest parse error

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