Error Codes

Every diagnostic silt reports has a code. The terminal shows its kind (error[type], warning[type]); silt check --format json and the language server give the code itself: E and four digits for an error, W and four digits for a warning. Its hundreds say when the problem was found: 0 lexing, 1 parsing, 2 names, 3 types, 4 compiling, 5 the entry point, 6 packages, 7 running, 8 formatting. A code is always an error or always a warning, and keeps its meaning; numbers that are missing belong to codes that are gone.

Lexing (0xx)

CodeMeaning
E0001A character that starts no token.
E0002A string that is not closed before the end of the file.
E0003A {- -} comment that is not closed before the end of the file.
E0004A backslash in a string that starts no escape silt has.
E0005A number literal that is not well-formed, or out of its type’s range.

Parsing (1xx)

CodeMeaning
E0101A token other than the one the grammar needs here.
E0102A name is needed here.
E0103A declaration (fn, type, trait, let, import) is needed here.
E0104An expression is needed here.
E0105A pattern is needed here.
E0106A type is needed here.
E0107A list, block or call that is not closed where it ends.
E0108Two declarations, or two statements, on one line.
E0109Syntax of another language, or of an older silt, that silt does not have.
E0110A name bound twice at the top level of a file.
E0112Expressions, patterns or types nested deeper than the parser follows.
E0113A declaration whose parts are not allowed together (a supertrait on an impl, an annotated type parameter, opaque on an alias or on a private type, …).
E0114The count of the lex and parse errors of a file that are not shown, at the last character of the last error that is shown.
E0115A name whose first letter breaks the naming rule: a function, a record field or a module alias that starts with a capital, a type or trait parameter that does not start with a lower-case letter (T, _t, _), a type, an enum variant or a trait that starts with a lower-case letter.
E0116as behind a name, _ or another as in a pattern, or behind a pattern that tests and binds nothing ((_, _), [..], P { .. }): a name already binds the whole value.
E0117A map pattern without keys, #{}: it tests nothing and matches every map; _ is the pattern that takes every map.

Names (2xx)

CodeMeaning
E0201A name that resolves to nothing where it is used.
E0202A bare variant name that variants of several enums share.
E0203A member a module does not have: m.nope, import m.{ nope }, m.Nope as a type, trait or variant.
E0204A name of another module that is not pub there.
E0205A name in a closure that is both the closure, which its let binds to the name, and what the name meant before that let.

Types (3xx)

CodeMeaning
E0301A value of one type where another type is needed.
E0302A name in a pin pattern (^x) that nothing binds.
E0303A constructor that no enum declares.
E0304A record literal or pattern whose type name names no record type.
E0305A field or method that the type at hand does not have: p.b on a record without b, a field a record literal or update gives that its type does not declare.
E0306A field that the record at hand does not declare.
E0307A record literal without a field its type needs.
E0308A method that the value’s type does not have.
E0309A method called in a way it cannot be (a method without self on a value).
E0310A method several traits provide.
E0311A variant that the enum does not declare.
E0312A type name in an annotation that names no type.
E0313A trait name that names no trait.
E0314A type has no impl of a trait it is required to have.
E0316A call needs a trait bound the enclosing function does not declare.
E0317The wrong number of arguments, fields, bindings or type arguments.
E0318A type that would have to contain itself.
E0319A type that cannot be determined.
E0320A match that does not cover every value.
E0322A pattern that cannot stand where it is (a refutable let, an or-pattern whose alternatives bind different names, …).
E0323A name bound twice in one pattern.
E0324? where it cannot propagate.
E0325A when else body that does not end, or a function declared to return Never that can return (its body, a return or a ?).
E0326An operation the operand types do not support.
E0328A use of a builtin module that is not imported.
E0330A trait declaration that breaks a trait rule.
E0331An impl that breaks a trait rule: a missing or undeclared method, a hand-written impl of a derived trait, …
E0332An impl written in a module that declares neither its trait nor its type.
E0333Two declarations of one name.
E0334A record, enum or alias declaration that is not well-formed.
E0335A type annotation or bound that is not well-formed.
E0336A name that hides another one where both are needed.
E0338A field named twice in a record type, literal, pattern or update, or a key written twice as the same constant in a map literal or pattern.
E0339A top-level let whose initialiser can reach the let itself.
E0340A statement whose value nothing uses.
E0342A type given to a decoder that has no decoder for it (a field of a type no decoder exists for, an enum, a generic type without its type arguments, a type nested past the limits of what a decoder reads where it is written at the call, …), or an opaque type decoded or json-encoded outside its module without the module’s impl, or a call of a trait method whose methods call each other at more types than the check follows (1,500), so what it gives decoders is not known (a default method calling itself on self hands its types on as a function does, and is not counted).
E0343A type constructor where a type is needed, or a type where a type constructor is needed.
E0344A value of an opaque type built, taken apart, updated or read outside its module.
E0345A function, or a group of functions that call each other, that takes a frame for every round without descending on a parameter: a call that is not a tail call and does not pass a part of a parameter, a tail call that passes something bigger than a part, a call inside a closure, a function passed as a value (see Repeating).
E0346A function that gives (), of a group whose calls of each other are all tail calls, that ends somewhere without saying so: a call that gives (), or a block that ends in a let (see Repeating).

Compiling and the entry point (4xx, 5xx)

CodeMeaning
E0401An import of a module that is not there.
E0402Modules that import each other in a cycle.
E0405Something the bytecode cannot express: too many constants, locals, arguments, a jump too far.
E0409A defect in silt: the compiler lost track of its own state.
E0410A module file, or an import, whose name is not a module name: named like a builtin module (import of the name always means the builtin one; an import alias too), a keyword, or not lowercase letters, digits and _ starting with a letter or _.
E0411A host module an embedder declared that a builtin module, a dependency or a module file of the same name hides or is hidden by.
E0412A host function whose signature is not one fn header, or a host type that is not one record or enum declaration.
E0501silt run of a program without a main function.
E0502A main that takes parameters, returns something other than () or Result((), e), or returns an error type with no Display.
E0503A test function that cannot be called with no arguments, returns something other than () or Result((), e), or returns an error type with no Display.

Packages (6xx)

CodeMeaning
E0601A silt.toml that is not well-formed.
E0602A path dependency whose directory is not there.
E0603A dependency whose directory holds no silt.toml.
E0604One repository required at two commits, or at one commit by URLs written in different ways.
E0605A dependency key equal to a module of the same package.
E0606A git dependency that cannot be resolved or fetched.
E0607A silt.lock that is not well-formed.
E0608A silt.lock entry that is not what the manifest resolves to, where the lockfile may not be rewritten.
E0609A symbolic link in a dependency’s sources.
E0610A package file that cannot be read or written.
E0611A git dependency’s checkout whose checksum is not the one silt.lock pins.
E0612A package that depends on itself, or names one package by two dependency keys.
E0613A dependency that a package fetched over git names outside its own checkout: a path that leaves it, or a repository on this machine.

Running (7xx)

CodeMeaning
E0701A runtime error: a panic, a division by zero, an out-of-range conversion, …
E0702main, or a test function, returned Err(..).
E0703A failure that nothing read: a stream stage failed and nobody read its output, or the handler of an http.serve that a test started called process.exit.
E0704An instruction met a value of a kind it cannot work on: the typechecker let through a program it should have rejected.

Formatting (8xx)

CodeMeaning
E0801silt fmt could not follow the tokens of a file that parses, or its result failed its own check: a defect of the formatter. The text is left as it is.

Warnings (Wxxx)

A warning never stops silt run, silt test or the REPL; silt check --deny-warnings exits with 1 when there is one. Its help line names the fix, which is the one way to silence it.

CodeMeaning
W0201A local that hides an imported module, an alias or an imported name.
W0202An import that nothing in the file uses.
W0203A let name or a pattern name that nothing reads.
W0204A private function that nothing in its module calls: not main, a test, a pub function, an impl’s or a trait’s method, a top-level let, nor a function they call (one that only calls itself counts as unused).
W0301A deep fn the recursion check would accept without deep.
W0302A let-bound _name in scope at a tail call that ends its block: the call lets it go before it runs.
W0303An arm of a match, or an alternative of an arm’s or-pattern, that never matches: the arms before it take every value it would. In a match without a scrutinee, an arm after one that always matches (_, or the condition true).
W0304A condition or guard that is the literal true or false: in a match without a scrutinee, a condition true is _ written another way; in a match on a value, a guard when true tests nothing; a condition or guard false is an arm that never runs.