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)
| Code | Description |
|---|---|
| E1001 | Expected token missing in current grammar position |
| E1002 | Unexpected token for current grammar rule |
| E1003 | Invalid type syntax |
| E1004 | Invalid character during lexing |
| E1005 | Unterminated string literal |
| E1006 | Invalid assignment target in statement syntax |
| E1007 | result type prefix is missing its inner type |
| E1008 | ptr or slice type prefix is missing its inner type |
Semantic errors (E3xxx)
| Code | Description |
|---|---|
| E3001 | Duplicate function name |
| E3002 | Unknown name |
| E3003 | Duplicate local binding in the same scope |
| E3004 | Type mismatch |
| E3005 | Control-flow condition is not bool |
| E3006 | Assignment to immutable binding |
| E3007 | Non-void function does not return on every path |
| E3008 | Incorrect function call arity |
| E3009 | Unknown or invalid field access |
| E3010 | Invalid indexing target |
| E3011 | Array literal size mismatch |
| E3012 | Unknown declared type or module-qualified type without matching import |
| E3013 | Duplicate struct name |
| E3014 | Invalid call target or module-as-value usage |
| E3015 | err used without an expected result type |
| E3016 | Duplicate import alias |
| E3017 | Module file could not be resolved or loaded |
| E3018 | Cyclic module import |
| E3019 | free requires a pointer or string value |
| E3020 | Internal typed IR lowering invariant failed |
| E3021 | LLVM backend does not support the requested feature yet |
| E3022 | External backend toolchain step failed |
| E3023 | Public API exposes a private type |
| E3024 | result.value used without a proven-ok check |
| E3025 | Module-level constant initializer uses a runtime-only operation |
| E3026 | Cyclic module-level constant definition |
| E3027 | Duplicate or conflicting top-level constant name |
| E3028 | Integer literal is out of range for the target type |
| E3029 | if expression branch does not produce a value |
| E3030 | if expression branch types do not match |
| E3031 | addr target is not addressable |
| E3032 | deref requires a pointer value |
| E3033 | try used outside a result ... function |
| E3034 | try initializer is not a result ... value |
| E3035 | addr cannot target an immutable binding |
| E3036 | addr cannot target a module constant |
| E3037 | free cannot release a slice value |
| E3038 | free cannot release a result wrapper directly |
| E3039 | Array size must be a non-negative integer constant |
| E3040 | Array repeat count must be a non-negative integer constant |
| E3041 | zalloc requires an enclosing zone block |
| E3042 | Zone-owned value cannot escape through return |
| E3043 | free cannot release zone-owned memory |
| E3044 | Zone-owned value cannot escape into outer storage |
| E3045 | Zone-owned value cannot cross a function call boundary yet |
Runtime memory errors (R4xxx)
| Code | Description |
|---|---|
| R4001 | Allocation failed |
| R4002 | realloc used on an unmanaged pointer |
| R4003 | free used on an unmanaged pointer |
| R4004 | Memory leak summary reported at shutdown |
| R4005 | Leaked allocation detail reported at shutdown |
| R4006 | Allocation size overflow |
| R4008 | realloc failed and preserved the original pointer |
| R4009 | realloc size overflow |
| R4010 | Double free detected |
| R4011 | free used on an interior pointer instead of the allocation start |
| R4013 | Use-after-free detected within the quarantine window |
| R4016 | Buffer overflow detected by allocator guard checks |
| R4017 | Buffer 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.