#[non_exhaustive]pub enum DiagCode {
Show 98 variants
UnexpectedToken,
UnterminatedString,
InvalidEscape,
InvalidNumber,
FullWidthSpace,
UnknownName,
UnknownCommand,
UnknownLabel,
UnknownType,
TypeMismatch,
ConditionNotBool,
ArgCount,
UnknownArgument,
DuplicateArgument,
MissingArgument,
ArgumentOutOfOrder,
PositionalAfterNamed,
RequiredAfterDefault,
DuplicateName,
DuplicateStableId,
InvalidStableId,
UnboundSugar,
UnterminatedBlock,
UnexpectedClose,
ElseWithoutIf,
StatementOutsideLabel,
NotConstant,
NotYetSupported,
TooDeep,
UnexpectedEol,
BlockTooDeep,
TooManyRegisters,
InvalidOperation,
DeclarationNotAllowed,
OutsideLoop,
ShadowedBuiltin,
ImportNotFirst,
UnknownModule,
ModuleNotImported,
DuplicateModule,
InvalidModuleName,
PackageAlias,
DuplicateImport,
UnusedImport,
UnusedVariable,
JumpToCallableLabel,
JumpInReturningLabel,
CallInExpression,
CallWithoutValue,
MissingReturn,
MissingReturnValue,
UnexpectedReturnValue,
LabelFallsThrough,
UnterminatedQuote,
UnclosedBracket,
TextAfterQuote,
OnceWithoutId,
EmptyChoice,
SchemaNameOutsideMigrations,
InvalidSchemaFile,
SchemaHashMismatch,
DuplicateMigrate,
InvalidMigrateVersion,
InvalidMinSaveVersion,
UnknownSchemaName,
MigrateKindMismatch,
MigrateTypeMismatch,
DuplicateMigrateTarget,
MigrateImpureExpr,
MissingFrozenSchema,
MissingMigrate,
UnhandledTypeChange,
SchemaChangedSinceFreeze,
AmbiguousIdentity,
IdentityTypo,
UnknownPosition,
UnknownLabelLiteral,
InvalidCommandUse,
AssignToReadOnly,
NonExhaustiveMatch,
UnreachablePattern,
UnknownField,
UnknownVariant,
MissingField,
DuplicateField,
RecursiveType,
CannotInferType,
UnknownMethod,
StatementMethodInExpression,
UnsupportedElementType,
InvalidMapKey,
NotAllowedInFn,
AssignInFn,
UnknownFunction,
MissingTextId,
DeprecatedCommandName,
FnNotSaveable,
ReplNotAllowed,
}Expand description
A diagnostic code. as_str is the stable English name.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnexpectedToken
An unexpected token. Argument found.
UnterminatedString
A string literal is not closed.
InvalidEscape
An escape that cannot be used. Argument found.
InvalidNumber
Cannot be read as a number. Argument text.
FullWidthSpace
There is a full-width space in code.
UnknownName
An undeclared name. Argument name, and suggestions if there are close names (up to 3, closest first).
UnknownCommand
An unregistered command. Argument name, and suggestions if there are close names.
UnknownLabel
A label that does not exist. Argument name, and suggestions if there are close names.
UnknownType
An unknown type name. Argument name.
TypeMismatch
Types do not match. Arguments expected, found.
ConditionNotBool
A condition is not bool. Argument found.
ArgCount
The number of arguments does not match. Arguments name, expected, found.
UnknownArgument
There is no parameter with that name. Arguments name (what was called), arg (the parameter name).
DuplicateArgument
The same argument was passed twice. Arguments name, arg.
MissingArgument
A parameter without a default value was not passed. Arguments name, arg.
ArgumentOutOfOrder
Named arguments are not in declaration order. Arguments name, arg.
PositionalAfterNamed
A positional argument was written after a named argument. Argument name.
RequiredAfterDefault
A parameter without a default value was declared after one with a default value. Arguments name, arg.
DuplicateName
Names collide. Argument name.
DuplicateStableId
A stable ID collides within the same label. Argument id.
InvalidStableId
The form of a stable ID is invalid. Argument id.
UnboundSugar
A sugar is not bound. Argument kind.
UnterminatedBlock
A block is not closed.
UnexpectedClose
A } without a matching opening.
ElseWithoutIf
An else without an if.
StatementOutsideLabel
There is a statement or text outside a label.
NotConstant
An initial value that is not a constant.
NotYetSupported
Syntax that is not implemented yet (but is in the spec). Argument what (a call of a name that cannot be called,
call; a postfix call, postfix expression; the name of a return type that cannot be stored in a variable; and so on).
TooDeep
Expressions are nested or chained too deeply. Argument limit.
UnexpectedEol
A line ends where more was expected.
BlockTooDeep
Blocks are nested too deeply. Argument limit.
TooManyRegisters
One label or fn uses too many registers (local variables and temporaries) (the register backend). Argument limit.
InvalidOperation
An operation that cannot be used on this type. Arguments op (the operator, such as +, <, -, +=), type
(the type of the operand).
DeclarationNotAllowed
A declaration that cannot be written inside a label (such as save var). Argument what (the first word).
OutsideLoop
break / continue outside a loop. Argument what (break or continue).
ShadowedBuiltin
A variable was declared with the same name as a built-in function (warning). Argument name.
ImportNotFirst
An import is written after other declarations.
UnknownModule
A module that does not exist. Argument name, and suggestions if there are close names (up to 3, closest first).
ModuleNotImported
A module that is not imported was used. Argument name.
DuplicateModule
Module names collide. Argument name.
InvalidModuleName
A module name is not a valid identifier. Argument name.
PackageAlias
An alias was given with as to the import of a package. Argument name (the package name).
DuplicateImport
A name used by an import collides with a name already imported (an alias can be given with as). Argument name.
UnusedImport
imported but not used (warning). Argument name (the path written in the import).
UnusedVariable
A local variable declared with let is never read (warning). Argument name.
JumpToCallableLabel
A jump to a label that has parameters or a return type (it can only be called with call). Argument name.
JumpInReturningLabel
A jump inside a label that has a return type (it could no longer return a value to the caller). Argument name
(the name of that label).
CallInExpression
A call in the middle of an expression (it can only be written on the right-hand side of let or =, or as a
statement).
CallWithoutValue
Tried to receive the value of a label that has no return type. Argument name.
MissingReturn
A label with a return type may reach its end without return. Argument name.
MissingReturnValue
A return without a value in a label with a return type. Argument expected (the type name).
UnexpectedReturnValue
A return with a value in a label without a return type.
LabelFallsThrough
A label that is never called and does not end with jump / return / end (warning). Argument name.
UnterminatedQuote
The 「 of a quote line or an option is not closed by 」 (quote lines with an identity, and option texts).
UnclosedBracket
A bracket of an expression is not closed by the end of the file or the limit of continuation lines. Argument open.
TextAfterQuote
In a quote line with an identity, characters other than spaces and a stable ID follow 」.
OnceWithoutId
An option with once has no stable ID.
EmptyChoice
A choice with no options.
SchemaNameOutsideMigrations
A versioned name (v2::…) written outside the migrations module. Argument name.
InvalidSchemaFile
A frozen schema file with a wrong file name or header. Argument path.
SchemaHashMismatch
The content of a frozen schema does not match its recorded hash. Argument version.
DuplicateMigrate
Two migrate blocks of the same version. Argument version.
InvalidMigrateVersion
A migrate version below 2. Argument version.
InvalidMinSaveVersion
A wrong min_save_version (out of range, repeated, not first). Argument version.
UnknownSchemaName
A name not in the schema of that version. Arguments name, version, and suggestions if there are close names.
MigrateKindMismatch
A rename between a save var and a persistent var. Argument name.
MigrateTypeMismatch
A written type differs from the schema’s type. Arguments name, expected, found.
DuplicateMigrateTarget
The same variable handled twice in one migrate. Argument name.
MigrateImpureExpr
Something not allowed in a conversion expression. Argument what.
MissingFrozenSchema
A needed frozen schema is missing. Argument version.
MissingMigrate
A needed migrate block is missing. Argument version.
UnhandledTypeChange
A variable whose type changed is not handled by migrate (warning). Arguments name, version.
SchemaChangedSinceFreeze
The schema changed after the latest freeze but there is no newer migrate (warning). Argument version.
AmbiguousIdentity
An identity with the same name exists in multiple imported modules. Arguments name, candidates (a list of
module.name).
IdentityTypo
A plain line where an undeclared name is followed by 「, and there is an identity with a close spelling (warning).
Arguments name, suggestions.
UnknownPosition
The string literal passed to seen is not the position of an existing stop point (warning). Argument position.
UnknownLabelLiteral
The string literal passed to visited is not an existing label (warning). Argument label.
InvalidCommandUse
A use that does not fit the kind of command (an effect or stop command called inside an expression, a query command
called as an @ statement, an @ call in the middle of an expression, or an @ call of a command returning () or of
a query command on the right-hand side of let or =).
Arguments name (the command name), kind (effect, query, stop).
AssignToReadOnly
Assignment to a read_only variable. Argument name (package.variable).
NonExhaustiveMatch
A match does not cover all values. Argument missing (a list of missing patterns, such as None, Dir.South,
_).
UnreachablePattern
An arm of a match is hidden by an earlier arm and is never chosen (warning).
UnknownField
A field the type does not have. Arguments name (the field name), type (the type name), and suggestions if there
are close names.
UnknownVariant
A variant the type does not have. Arguments name (the variant name), type (the type name), and suggestions if
there are close names.
MissingField
A struct literal is missing a field. Arguments name (the field name), type (the type name).
DuplicateField
The same field is written twice (in a struct declaration or literal). Argument name.
RecursiveType
A type that contains itself (directly or through other types). Argument name (the type name).
CannotInferType
An expression whose type cannot be decided ([] or None without a type annotation). Add a type annotation
(let xs: list<int> = []).
UnknownMethod
A method the type does not have. Arguments name (the method name), type (the name of the receiver’s type).
StatementMethodInExpression
A method that updates a variable (push, remove, clear) was called inside an expression. Write it as a statement.
Argument name.
UnsupportedElementType
A list method that needs ordered or summable elements (sort, sort_by, min_by, max_by, sum) was used with a
type that is not int, float, str or bool (sum: int or float). Arguments method and type (the type of
the elements, or of the keys for sort_by, min_by and max_by).
InvalidMapKey
A type that cannot be a map key (float, list, map, Option, and structs and enums containing them).
Argument type (the name of the type written as the key).
NotAllowedInFn
A statement that cannot be written inside a fn (quote lines, plain lines, choice, jump, call, end, and
effect and stop commands). Argument what (plain, quote, choice, jump, call, end; for commands, the name
with @, such as @audio.play).
AssignInFn
Tried to write to a save var, a persistent var or a host-declared variable inside a fn (reading is fine).
Argument name (the name of the written variable; variables of other modules are module.name).
UnknownFunction
An undeclared fn (a call name(...), module.name(...) or @name(...)). Argument name, and suggestions if
there are close names (up to 3, closest first).
MissingTextId
A text line (plain line, quote line or option text) without a stable ID while CompileOptions::require_text_ids is
enabled. Argument kind (plain, quote, choice).
DeprecatedCommandName
A command was called by an old name (alias) (warning). Arguments name (the old name written), new (the current
name).
FnNotSaveable
Tried to put a value containing a function type in a place that goes into saves. Arguments type (the type name),
what (var: save var or persistent var; field: a field or argument of a struct or enum; stop: a local
variable that lives across a stop point; call: a local variable that lives across a call; repl: a REPL let).
ReplNotAllowed
Something that cannot be written in REPL input (section 7.7 of spec/host/07-repl.md). Argument what (stable_id,
once, save, persistent, label, jump, end, return (outside a fn)).
Implementations§
Source§impl DiagCode
impl DiagCode
Sourcepub const ALL: &'static [DiagCode]
pub const ALL: &'static [DiagCode]
All codes (used to check that translation keys are complete).
Sourcepub fn severity(self) -> Severity
pub fn severity(self) -> Severity
The severity of this code (codes other than warnings are errors).