vm: prescriptive error for '+' on lists (#680)#682
Merged
Conversation
`[1,2] + [3,4]` reported `cannot apply '+' to list and list` — correct but not actionable. A Python/JS prior lands here (observed live: an AI given only a syntax primer wrote `xs + [v]` and crashed) and has to guess the idiom. The message now names the fix, mirroring the existing mixed-type f-string hint: cannot apply '+' to list and list (use 'append of [xs, v]' to add an element, or 'concat of [a, b]' to join two lists) Cold error path (rt_error), no hot-path cost. dict+num and other non-list cases keep the generic message; mixed str+X keeps the f-string hint. First of the prescriptive-error pass (#680): at points where the language diverges from mainstream priors, teach the fix — helps humans and AI alike, and a context-rich AI stumbling there is a lower bound on human friction. Regression: EE20b. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… our own Contributors work from forks we can't push to, so if our merge stales their PR the only fixes are asking them to rebase or the fetch-reland dance (#657). We rebase our own for free. So: land ready contributor PRs first, then rebase ours. Folded here rather than a standalone docs PR to avoid a wasted CI cycle. Co-Authored-By: Claude Opus 4.8 <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.
First concrete output of the prescriptive-error pass (#680).
What
[1,2] + [3,4]reportedcannot apply '+' to list and list— correct, but not actionable. A Python/JS prior lands here and has to guess the idiom. The message now names the fix, mirroring the existing mixed-type f-string hint:Scope / safety
rt_error) — no hot-path cost.dict + numand other non-list mismatches keep the generic message; mixedstr + Xkeeps the f-string hint (verified).appendandconcatare both real builtins, so the suggestions are valid.Why
At points where the language diverges from mainstream priors, errors should teach the fix — for humans and AI alike. A context-rich AI stumbling here is a lower bound on human friction (it was observed live: an AI given only a syntax primer wrote
xs + [v]and crashed). This is the first site; the catalog of others is in #680.Tests
test_error_extra.eigsEE20b pins the new prescriptive text (asserts the message names bothappend ofandconcat of). Full suite 3113/3113 release, 3134/3134 ASan+leaks.Closes #680 is premature — this is one site of several; references #680.
🤖 Generated with Claude Code