Skip to content

Error Codes

cnegc diagnostics use stable error codes so errors can be documented and referenced consistently. All diagnostics show source path, line, and column.

Parse errors (E1xxx)

CodeDescription
E1001Expected token missing in current grammar position
E1002Unexpected token for current grammar rule
E1003Invalid type syntax
E1004Invalid character during lexing
E1005Unterminated string literal
E1006Invalid assignment target in statement syntax
E1007result type prefix is missing its inner type
E1008ptr or slice type prefix is missing its inner type

Semantic errors (E3xxx)

CodeDescription
E3001Duplicate function name
E3002Unknown name
E3003Duplicate local binding in the same scope
E3004Type mismatch
E3005Control-flow condition is not bool
E3006Assignment to immutable binding
E3007Non-void function does not return on every path
E3008Incorrect function call arity
E3009Unknown or invalid field access
E3010Invalid indexing target
E3011Array literal size mismatch
E3012Unknown declared type or module-qualified type without matching import
E3013Duplicate struct name
E3014Invalid call target or module-as-value usage
E3015err used without an expected result type
E3016Duplicate import alias
E3017Module file could not be resolved or loaded
E3018Cyclic module import
E3019free requires a pointer or string value
E3020Internal typed IR lowering invariant failed
E3021LLVM backend does not support the requested feature yet
E3022External backend toolchain step failed
E3023Public API exposes a private type
E3024result.value used without a proven-ok check
E3025Module-level constant initializer uses a runtime-only operation
E3026Cyclic module-level constant definition
E3027Duplicate or conflicting top-level constant name
E3028Integer literal is out of range for the target type
E3029if expression branch does not produce a value
E3030if expression branch types do not match
E3031addr target is not addressable
E3032deref requires a pointer value
E3033try used outside a result ... function
E3034try initializer is not a result ... value
E3035addr cannot target an immutable binding
E3036addr cannot target a module constant
E3037free cannot release a slice value
E3038free cannot release a result wrapper directly
E3039Array size must be a non-negative integer constant
E3040Array repeat count must be a non-negative integer constant
E3041zalloc requires an enclosing zone block
E3042Zone-owned value cannot escape through return
E3043free cannot release zone-owned memory
E3044Zone-owned value cannot escape into outer storage
E3045Zone-owned value cannot cross a function call boundary yet

Runtime memory errors (R4xxx)

CodeDescription
R4001Allocation failed
R4002realloc used on an unmanaged pointer
R4003free used on an unmanaged pointer
R4004Memory leak summary reported at shutdown
R4005Leaked allocation detail reported at shutdown
R4006Allocation size overflow
R4008realloc failed and preserved the original pointer
R4009realloc size overflow
R4010Double free detected
R4011free used on an interior pointer instead of the allocation start
R4013Use-after-free detected within the quarantine window
R4016Buffer overflow detected by allocator guard checks
R4017Buffer underflow detected by allocator guard checks

Diagnostic style

  • Show source path, line, and column.
  • One clear primary sentence per diagnostic.
  • Prefer describing both expected and actual types for mismatches.
  • Reject ambiguous truthiness in conditions with E3005.
  • Report missing struct fields directly at the literal or access site.
  • Recover after common syntax mistakes when possible so multiple real errors can be reported in one pass.

cnegative docs track the current v0.5.2 compiler surface.