feat: Gleam-style todo/panic typed expressions (ILO-410)#706
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Implements `todo "reason"` and `panic "reason"` as typed expressions that satisfy any return type at the verifier and abort at runtime with the given message. Covers parser (contextual idents), AST nodes (Expr::Todo/Panic), verifier (Ty::Unknown), tree interpreter (ILO-R020/ILO-R021), VM compiler (OP_WRAPERR + OP_PANIC_UNWRAP), and all expression-walking traversals (graph, codegen/fmt, codegen/python, desugar, alias-resolve, free-var). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
c768c80 to
bcaba1e
Compare
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
todo "reason"andpanic "reason"as typed expressions that satisfy any return type (like Gleam's divergent expressions)todo/panicas contextual identifiers in any expression position, each followed by a mandatory reason expressionTy::Unknownso both expressions satisfy any expected return type without emitting type errorstodoraisesILO-R020,panicraisesILO-R021, both include the reason string in the error messageOP_WRAPERR+OP_PANIC_UNWRAPto abort with the reason at runtimeCloses ILO-410.
Test plan
cargo testpasses (all existing tests green)verify_todo_satisfies_number_return/verify_todo_satisfies_text_return— type checks passverify_todo_in_branch— todo as one branch of a ternary typecheckstodo_expr_produces_runtime_error— ILO-R020 with correct messagepanic_expr_produces_runtime_error— ILO-R021 with correct message🤖 Generated with Claude Code