You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Three Python-grade ergonomic gaps closed in one push.
* String + concat. `"count: " + 42` now produces "count: 42" instead
of returning 0 via int coercion. Added Value::to_display_string()
for bare-number stringification (concat_many's existing logic
centralized into one helper); both tree-walk Expression::Add and
VM arith_add use it when either operand is a string.
* Dictionaries / hash maps. New Value::Dict variant backed by
BTreeMap<String, Value> (sorted-key iteration; deterministic for
tests). Literal syntax `{"k": v, ...}`. Indexing via `d["key"]`
routes through the same Op::ArrayIndex now made polymorphic
(dispatches on container type). Nine builtins: dict_new / dict_get
/ dict_set / dict_has / dict_del / dict_keys / dict_values /
dict_len / dict_merge. dict_get takes an optional default arg.
VM gets dedicated Op::DictSetNamed / Op::DictDelNamed for
mutating operations — same name-on-opcode pattern as
Op::ArrPushNamed solves the synthetic-arg-shim mutation loss.
* try/catch error handling. `try { ... } catch err { ... }`. The
caught value is a Value::String holding the error message;
builtin failures and the new `error("msg")` builtin both raise.
VM compiles Statement::Try to Op::ExecStmt — a tree-walk fallback
that runs the AST node via the embedded Interpreter. Pragmatic
choice: full exception unwind would require either a side
try-stack or a Result-aware op dispatch loop refactor; this
costs only a tree-walk per try block, which is rare in hot paths.
Critical detail: after Op::ExecStmt the VM drains
interp.return_value via a new vm_take_return helper, so a
`return` inside a try body correctly bubbles out of the
surrounding VM-compiled function.
40/40 functional examples produce byte-identical output under
tree-walk and VM. 92/92 unit tests pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
0 commit comments