Skip to content

Latest commit

 

History

History
296 lines (286 loc) · 16.5 KB

File metadata and controls

296 lines (286 loc) · 16.5 KB

Compiler diagnostics

List of diagnostics that the compiler can produce. In the future, we will add a description of each diagnosis with examples here. This description will be used to generate documentation and the --explain flag.

Lexer

  • E0001: Unexpected input character

  • E0002: Not closed string literal

  • E0003: Not closed block comment

  • E0004: Not closed rune literal

  • E0005: Usage of a reserved identifier

  • E0006: Invalid digit in literal

  • E0007: Literal has no digits

  • E0008: Invalid digit separator

  • E0009: Invalid radix point

  • E0010: Wrong mantissa for exponent

  • E0011: Illegal character NUL

  • E0012: Illegal byte order mark

  • E0013: Unknown string prefix

  • E0014: Rune literal cannot be empty

  • E0015: Rune literal cannot contain new line in source code

  • E0016: Rune literal cannot contain more than one character

  • E0017: Unknown escape sequence

  • E0018: Escape sequence is not terminated

  • E0019: Illegal character in escape sequence TODO: Check IDs must then be re-numbered

  • E0019.1: Escape sequence is invalid Unicode code point

  • E0019.2: Escape sequence is invalid octal number

  • E0019.3: Unknown rune literal prefix

  • E0019.4: Byte literal cannot contains non-ASCII character

  • E0019.5: Escape sequence is invalid byte value

  • E0019.6: Byte literal cannot contain escape sequence with Unicode code point

  • E0019.7: String literal cannot contain \0 character

  • E0019.9: Not terminated string interpolation

  • E0019.10: No need to escape $ in C string literal

Parser

  • E0020: Not expected token
  • E0021: Missing condition in if expression
  • E0022: Method receiver must have a name
  • E0023: Method receiver must have a type
  • E0024: Multiline comments cannot be used in array literal
  • E0025: Result type should have one or two types in ![]
  • E0026: Prefix ++/-- is not supported
  • E0027: No need to specify : in type declaration
  • E0028: Parameter should have a name
  • E0029: Invalid comparison operator (=== and !== are not supported)
  • E0030: Too many expressions for fixed array size
  • E0031: Import alias cannot be qualified
  • E0032: To declare multiple constants use const ( ... ) syntax
  • E0033: Constant definition cannot have a type annotation
  • E0034: Return types are denoted using ->
  • E0035: ...foo update syntax is allowed only as first expression
  • E0036: Use $if/$else instead of if/else in compile time if
  • E0037: Cannot use a := foo() in comptime if condition
  • E0038: To declare multiple vars use var ( ... ) syntax
  • E0039: Missed [ after # in attribute
  • E0040: Match expression can have only one else branch
  • E0041: Multiply return types must be wrapped in parentheses
  • E0042: Function literals cannot have a name
  • E0043: Module var definition cannot have a type annotation

Type checker

  • E0050: Type mismatch
  • E0051: Cannot dereference a non-pointer type
  • E0052: Type incorrectly implements interface
  • E0053: Cannot index a non-array type
  • E0054: nil can be cast only to a pointer type
  • E0055: Generic type parameters count mismatch
  • E0056: Cannot pass a type as generic argument due constraint
  • E0057: Missed constraint for generic type parameter
  • E0058: Cannot instantiate a non-generic type
  • E0059: Generic argument in the method receiver must have the same name as the generic parameter in the declaration
  • E0060: Cannot use an Option type without unwrapping
  • E0061: No need to check a pointer type for nil because it cannot be nil by design (warning)
  • E0062: is condition is always true at this point (warning)
  • E0063: is condition is always false at this point (warning)
  • E0064: Pointer dereference requires unsafe block
  • E0065: Pointer arithmetic requires unsafe block
  • E0066: Pointer indexing requires unsafe block
  • E0067: or can only be used with Option or Result types
  • E0068: Cannot unwrap a non-Option and non-Result type
  • E0069: Cannot call expression of type name

Checker

  • E0070: Redeclaration of name
  • E0071: Shadowing of name
  • E0072: Variadic parameter must be the last parameter in the signature
  • E0073: Duplicate parameter name name
  • E0074: Wrong number of arguments
  • E0075: Return statement with expression in function with no return type
  • E0076: Return statement missing expression
  • E0077: Unknown field
  • E0078: Unknown method
  • E0079: Unresolved identifier
  • E0080: Cannot match on bare none, cast it to a concrete Option type first
  • E0081: Receiver type cannot be variadic
  • E0082: Literal cast overflow
  • E0083: C bindings should always use pointers instead references
  • E0084: Unknown interface method
  • E0085: Overflow while execute compile-time expression
  • E0086: Unreachable code (warning)
  • E0087: Not all code paths return a value
  • E0088: Assigned value is not used (warning)
  • E0089: Previous assigned value is not used (warning)
  • E0090: Unused variable (warning)
  • E0091: Break statements must be inside a loop
  • E0092: Continue statements must be inside a loop
  • E0093: Nested Option types are not allowed
  • E0094: Function result type cannot be void
  • E0095: Function without result cannot be used as a value
  • E0096: Function that never returns cannot be used as a value
  • E0097: Cannot use return in function that never returns
  • E0098: Unknown enum variant
  • E0099: Enum with no variants
  • E0100: Cannot check if a non-pointer type is nil/not-nil
  • E0101: Nested unsafe block is not allowed
  • E0102: Cannot iterate over a non-iterable type
  • E0103: Cannot determine a type of enum to fetch
  • E0104: main function cannot have parameters
  • E0105: main function cannot have a return type, to return a value use os.exit()
  • E0106: none can be cast only to an Option type
  • E0107: Option propagation can only be used with Option types
  • E0108: Option propagation can only be used in function that returns an Option type
  • E0109: Cannot infer a type of array
  • E0110: T{} initialization is only allowed for structs, aliases for structs, arrays, maps, and channels
  • E0111: Included file not found by C compiler
  • E0112: Access to .data of string literal can be replaced with C string (warning)
  • E0113: Complex boolean expression should use parentheses
  • E0114: Unused import (warning)
  • E0115: Shadowing of import name
  • E0116: Go-style cast is not supported
  • E0117: C binding arguments count mismatch
  • E0118: Deferred expression must be a function call
  • E0119: Duplicate field name name
  • E0120: Cannot cast rune literal to u8, use b prefix to create a byte literal
  • E0121: Comparison of unsigned integers with zero is always true or false (warning)
  • E0122: Cannot cast a pointer to a reference type
  • E0123: Cannot cast &void outside unsafe block
  • E0124: Not enough information to infer a type of lambda parameter
  • E0125: Unnecessary parentheses for if condition (warning)
  • E0126: if expression must have else branch
  • E0127: Division or modulo by zero
  • E0128: Cannot infer a type of generic parameter in call
  • E0129: Cannot increment or decrement expression of type
  • E0130: C binding functions cannot have a body
  • E0131: Cannot infer a type of generic parameter in type instantiation
  • E0132: Unsupported compile-time condition
  • E0133: Cannot use a type in string interpolation because it does not have str method
  • E0134: Cannot find module name to import
  • E0135: Cannot access private element name from module name
  • E0136: Cannot have a second variable in for loop over range
  • E0137: Cannot cast a type to interface name because it does not implement it
  • E0138: Unpacking expression must be the last argument in the call
  • E0139: Only arrays can be unpacked
  • E0140: Unpacking in array initializer is not allowed
  • E0141: is check is always false or true because a type not implements interface
  • E0142: Right operand of is operator must be a struct, interface, union or type alias
  • E0143: Implicit err variable can be used only when or block used for Result
  • E0144: Cannot take mutable reference to immutable variable
  • E0145: Cannot assign to immutable variable
  • E0146: Cannot break/continue to label since label is not directly attached to any enclosing loop
  • E0147: ! operator can be used only with bool type
  • E0148: || and && operators can be used only with bool type
  • E0149: Cannot cast an immutable pointer to mutable one
  • E0150: When or is used as an expression, it must have expression in the block
  • E0151: Cannot unpack expression as i-th argument in function
  • E0152: Spawn expression must be a function call
  • E0153: Forbidden cast
  • E0154: Integer literal too big to fit in i32 type
  • E0155: if expression body must end with expression, return statement or break/continue
  • E0156: Empty match expression (warning)
  • E0157: match expression with only else branch is not allowed
  • E0158: match expression with type arms can only be used with interface or union types
  • E0159: match arm expressions cannot have both types and values in the same arm
  • E0160: Cannot match type name because it is not implemented interface from match expression
  • E0161: match expression for enums must be exhaustive
  • E0162: match expression already matches all variants of enum E, so else branch is never executed
  • E0163: Unnecessary parentheses for match expression (warning)
  • E0164: Expression matched several times in match expression
  • E0165: match expression body must end with expression, return statement or break/continue
  • E0166: if condition must have bool
  • E0167: Cannot break/continue to label since label is outside current function literal
  • E0168: Unnecessary parentheses for for statement (warning)
  • E0169: Cannot increment or decrement immutable variable
  • E0170: Assignment count mismatch
  • E0171: Cannot unpack non-tuple type
  • E0172: Tuple type does not have any fields or methods
  • E0173: Wrong variable name in declaration
  • E0174: Cannot call static interface method
  • E0175: Cannot assign bare none to variable, cast it to a concrete Option type first
  • E0176: Cannot assign to expr because it is not a lvalue
  • E0177: Cannot declare variable _, this name is reserved for placeholders
  • E0178: Cannot assign bare nil to variable, cast it to a concrete pointer type first
  • E0179: Placeholder _ cannot be mutable
  • E0180: Wrong usage of placeholder
  • E0181: Cannot inc/dec non-lvalue expression
  • E0182: Placeholder _ is not needed here (warning)
  • E0183: Placeholder _ is invalid here
  • E0184: Unpacking expression is only allowed in function call or type initializer
  • E0185: Cannot access to fields for interfaces
  • E0186: .str() can be omitted in string interpolation because it is called implicitly (warning)
  • E0187: Variable in range expression cannot be mutable
  • E0188: Cannot get tuple element with index i because tuple has only n elements
  • E0189: Index of tuple must be a constant integer
  • E0190: Test name must be string literal
  • E0191: Test declaration cannot have a signature
  • E0192: Array initializer must have zero or one parameter
  • E0193: Array initializer must be a lambda expression
  • E0194: Array initializer parameter must have usize type
  • E0195: Cannot receive from a non-Channel type
  • E0196: Cannot receive from a non-Channel type
  • E0197: Only cap field can be specified for a Channel type
  • E0198: Only len, cap and init fields can be specified for an Array type
  • E0199: Only cap field can be specified for a Map type
  • E0200: Duplicate embedded interface
  • E0201: Embedded type in interfaces must be identifier, selector expression, or generic version of them
  • E0202: Only interfaces can be embedded in interface
  • E0203: Embedded interface X causes conflict for method Y
  • E0204: Result propagation can only be used with Result types
  • E0205: Result propagation can only be used in function that returns a Result type
  • E0206: Enum variant out of range for a backed type
  • E0207: Enum backed type must be one of u8, u16, u32, u64, i8, i16, i32, i64
  • E0208: Array index must be of type usize
  • E0209: Only init and no_init fields can be specified for a fixed array type
  • E0210: Unused return value of function name that must be used
  • E0211: Cannot evaluate constant expression
  • E0212: Duplicate enum value
  • E0213: Union type should have at least two types
  • E0214: Cannot call static method via instance
  • E0215: Cannot call instance method as static
  • E0216: Operator is not defined for a type
  • E0217: Cannot cast expression to Union because it's not one of its types
  • E0218: Right operand of is operator is not a member of the union type
  • E0219: Import names must have at least one name
  • E0220: Assert condition must have bool type
  • E0221: Assert message must have string type
  • E0222: Function has no parameter with such a name
  • E0223: Positional argument after named argument is not allowed
  • E0224: Duplicate named argument
  • E0225: Cannot access field of a pointer outside unsafe block
  • E0226: mut expression can be used only in variable declaration
  • E0227: Inclusive range ..= always panic in runtime due out of range
  • E0228: offset_of argument must be a string literal
  • E0229: Cannot get offset of non-struct type field
  • E0230: Cannot get field offset of unknown field
  • E0231: Cannot access field of C-style union struct outside unsafe block
  • E0232: Cannot initialize more than one field of C-style union struct
  • E0233: Cannot clone C-style union struct
  • E0234: Clone expression does not have any effect, because all fields are already initialized
  • E0235: Explicit Option propagation can be safely removed in return expressions (warning)
  • E0236: or { return none } can be safely removed in return expressions (warning)
  • E0237: Explicit Result propagation can be safely removed in return expressions (warning)
  • E0238: Cannot use safe access on a non-Option type
  • E0239: Cannot unpack Option/Result tuple, you need to unwrap an Option/Result type first
  • E0240: match expression for unions must be exhaustive
  • E0241: match expression already matches all members of union U, so else branch is never executed
  • E0242: Cannot cast a union type to another type because it's not one of its types
  • E0243: Cannot access enum variant via expression
  • E0244: Cannot match type name because it is not member of a union type
  • E0245: Add #[typedef] attribute to C struct
  • E0246: Cannot cast an immutable reference to mutable one
  • E0247: Match expression must have else branch
  • E0248: Enum variant value must have one of the following types:
  • E0249: Cast is always successful, use as instead of as?
  • E0250: Select expression with single timeout arm is not allowed
  • E0251: Invalid expression in select arm
  • E0252: Select expression with only timeout and else arm is not allowed, add at least one non timeout/else arm
  • E0253: Invalid statement in select arm, expected send, assign, var declaration or expression statement
  • E0254: Statement in select handled more than once
  • E0255: Select expression with only else arm is not allowed, add at least one non timeout/else arm
  • E0256: Reaching unwrap() call will always panic
  • E0257: Checking expression for none is always true/false
  • E0258: Cannot use ?. to access module members
  • E0259: Cannot create instance of generic type T without reflection.Struct constraint
  • E0260: Compiler error function call is reached
  • E0261: Compiler warning function call is reached (warning)
  • E0262: compiler_error and compiler_warning functions must have a string literal argument
  • E0263: Generic argument name in the method receiver must be an identifier
  • E0264: Cannot shift value of type T by X bits, maximum shift value is Y
  • E0265: Result of compile time constant folding overflows the maximum value of type T
  • E0266: Cannot shift value of type T by X bits, shift count is negative
  • E0267: Enum variant value overflow for type T
  • E0268: Cannot iterate with mutation over immutable string
  • E0269: Cannot iterate with mutation over a channel
  • E0270: Left and right operands of is operator are the same type, so this check is always true (warning)
  • E0271: Test files should be defined with main module name for now
  • E0272: Cannot slice a non-array and non-string type
  • E0273: Result type returned from function must be used