DEV Community

COMMENTERTHE9
COMMENTERTHE9

Posted on • Originally published at cx-lang.com

Cx Dev Log — 2026-04-14

Big day on submain. Six new commits landed and pushed the matrix from 78/78 green to 110/110 clean in a single sweep. Two critical features, the minimal error model and per-width integer overflow, got their long-awaited implementations, bringing us closer to resolve the hard blockers. Function bodies are now semicolon-optional without losing implicit returns, and we improved diagnostic readability. Plus, Part 1 of our parser/semantic/interpreter audit surfaced several real issues for future improvement. None of this hits main yet, though the submain backlog is 14 commits deep across three weeks. Here's what this all means.

Result, Ok, Err, and ?

The headline today is commit 02178a2 for the minimal error model. This involves new lexer keywords: KeywordResult, KeywordOk, and KeywordErr. We've added AST nodes Type::Result(Box) and expressions Expr::ResultOk, ResultErr, and Try. So, Result can now serve as a type, and expressions like Ok(expr)/Err(expr) can be parsed, while postfix ? knows its place. The semantic layer enforces Err() to take a string and confines ? to functions returning Result. Runtime deals with Ok and forwards Err through EarlyReturn. Value layer gains Value::ResultOk and Value::ResultErr with value_to_string and PartialEq. Tests t81 to t88 have cleared, covering all angles from happy paths to rejection cases. This crosses "Minimal error model" off our list for the interpreter path.

However, note that IR lowering for Results hasn't changed yet; it's still stuck with placeholder rejections from bcd49f2 two days ago.

Integer overflow at declared width

In dc564a7, we finally moved truncation to the right place. Now, binary and unary evaluations correctly employ apply_numeric_cast against the declared SemanticType. This means arithmetic like t8 + t8 wraps at 255 where it should, at the calculation, rather than just at assignment. Supporting changes let common_numeric_type opt for the wider declared integer type over default I128, and integer literals now flexibly adopt surrounding types as Numeric. The matrix tests t89 to t96 validated several scenarios, including t8 operations, wraparound actions, and mixed-width promotions.

We've talked about "wrapping at declared width" since v4.3 lock, but until today, it wrapped at i128, making this catch-up rather than innovation.

Still, "Integer overflow enforced" hasn't checked off yet. Our audit revealed audit_09, where a compound assignment like c.value += 10 with value: t8 incorrectly results in 260 instead of 4. The path for compound assignment on struct fields (CompoundAssign in run_semantic_stmt) doesn't yet apply width truncation. Fixing it is straightforward but pending.

Semicolons optional, implicit return preserved

Commit 6c27da0 lets trailing semicolons in function bodies become optional, preserving implicit returns when omitted. Each statement now gets tagged with whether it ends in a semicolon. A lone trailing ExprStmt sans semicolon upgrades to the function's return expression; add ;, and it becomes a discarded statement. The redundant parser helper expr_stmt_with_semi is gone. Tests t97 through t100 and a specific rejection t99_semi_suppresses_implicit_return.cx illustrate these rules.

This cements "trailing expression is meaningful syntax" as part of our grammar, without reducing everything to mere statements. General semicolon-free syntax remains a Known Gap, post-0.1 roadmap item, and we're holding off on checking the semicolon rule off the roadmap.

Diagnostics sweep

45f35c5 marks a significant clean-up; introducing a type_name helper maps SemanticType variants to Cx's syntax, letting I64 print as t64, Bool as bool, etc. We've gone through twelve out of thirteen sem_err! call sites ensuring user-facing errors ditch Rusty debug formats. Runtime error messages saw shine, too: UndefinedVar no longer mentions a let that isn't there, BadOperands now correctly names operand kinds, and unhandled EarlyReturn, BreakSignal, or ContinueSignal defaults to compiler-bug hints. We've covered these new, polished messages with matrix tests t101 to t103.

Audit Part 1

eb65acf represents our first dig into the audit with twelve tests under examples/audit/ and a full triage report in AUDIT_REPORT.md. The work split into 7 passes, 1 parse fail, 2 semantic fails, 1 wrong output and 1 panic. From that, we've categorized must-fixes, should-fixes, known limitations, and deferrals.

  • Must-fix by 0.1: Fix audit_09 as discussed.
  • Should-fix by 0.1: Tackle audit_02, where Result> fails due to a non-recursive inner type parser. It similarly affects other nested types.
  • Known limitations remain: audit_03/05 (untyped assignments need prior declarations) and audit_11 (stack overflow for recursive calls due to Rust limits).

We added five Phase 10 regression tests for loop constructs and cleaned up parser functionality in the same commit.

Roadmap and integration debt

We've updated docs/frontend/ROADMAP.md on main marking items like "Basic test runner" and "Minimal error model" as done. Yet, "Integer overflow enforced" and "Semicolon rule" remain unchecked until the evidence backs the claim. We also document key changes from v4.8 for submain, but it’s untidy; submain is on v4.7, creating a split in roadmap versions.

The integration's messy. There are fourteen submain work commits not on main, plus thirteen daily-log branches (up to daily-log-2026-04-12) still to merge. The expected "merge submain to main" has yet to happen, and this delay complicates roadmap divergence and the daily_log/ backlog, setting up an intense next integration phase.

What's next

The quickest fix is audit_09 for closing the overflow blocker. Post that, unlocking audit_02 aids nested generic handling. The main concern is a merge back to main; delay only compounds the entanglement. IR path Result remains pending, and the next audit phase could expand into arrays, imports, or nested generics.


Follow the Cx language project:

Originally published at https://cx-lang.com/blog/2026-04-14

Top comments (0)