interp: guide the [x y z] vector trap and add a signature builtin#86
Merged
Conversation
Loon's first end-user surface (the vcad Typst plugin) exposed two ergonomic failures that live in loon-lang: - [30 20 -1] is application, so a vector-literal habit yields the opaque "not callable: 30". All four not-callable sites (interp call + pipe paths, machine.rs, builtins::apply_value) now share not_callable_msg, which special-cases a numeric callee: it names the cause and shows the two correct spellings (#[30 ...] or separate args). - No way to discover a symbol's arity/arg names without reading source. New `signature` builtin: [signature translate] -> "[translate x y z s]" (multi-clause fns join with |, rest params show as `& name`, builtins report "[name ...] (builtin)"). Registered in the checker as a. a -> Str. The span already rides on err_at; the downstream vcad-loon change that threads it to a line number lives in the vcad repo. Tests: numeric-callee message on both the tree-walker and the VM, plain message preserved for non-numeric callees, and signature over named/anonymous/builtin/non-fn values. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What
Two ergonomic fixes in
loon-lang, surfaced by loon's first end-user-facing consumer (the vcad Typst plugin, where people write loon inline):1. The
[x y z]vector trap gets a guiding message[30 20 -1]is application, not a vector literal, so it evaluated to the opaquenot callable: 30. All four not-callable sites — the interp call path, the pipe path,machine.rs, andbuiltins::apply_value— now share a singlenot_callable_msghelper. For a numeric callee it names the cause and shows both correct spellings:Non-numeric callees keep the plain
not callable: <v>message. The error already carries a span viaerr_at; a companion vcad-loon change (separate repo) threads that span to a user-source line number.2.
signaturebuiltin for discoverabilityNo way previously to learn a symbol's arity/arg names without reading source.
[signature translate]→"[translate x y z s]". Multi-clause fns join with|, rest params render as& name, builtins report"[name ...] (builtin)". Registered in the type checker as∀a. a → Str(keeps the interp/checker builtin-parity test green).Why
These are the language-level halves of a three-problem ergonomics pass (full tradeoff writeup, including the vcad-side subject-last lint and span→line threading, is in
docs/plans/2026-07-18-subject-last-ergonomics.md). The design bar for the vector trap: make the wrong-input mistake loud and self-correcting at the moment it happens, without a parse-time ban that would outlaw legal macro-generated forms.Tests
cargo test --workspaceis green. New intests/interp_tests.rs:signatureover named, anonymous, builtin, and non-fn valuesReviewer notes
loon-lang. The vcad-loon consumer changes (VcadError line numbers,lint_vcadfor the subject-last B−A trap) land in the vcad repo separately.🤖 Generated with Claude Code