Skip to content

vm: prescriptive error for '+' on lists (#680)#682

Merged
InauguralPhysicist merged 2 commits into
mainfrom
prescriptive-list-plus-error
Jul 21, 2026
Merged

vm: prescriptive error for '+' on lists (#680)#682
InauguralPhysicist merged 2 commits into
mainfrom
prescriptive-list-plus-error

Conversation

@InauguralPhysicist

Copy link
Copy Markdown
Collaborator

First concrete output of the prescriptive-error pass (#680).

What

[1,2] + [3,4] reported cannot 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:

Error line 3: cannot apply '+' to list and list (use 'append of [xs, v]' to add an element, or 'concat of [a, b]' to join two lists)
     3 | c is a + b
       |        ^

Scope / safety

  • Cold error path (rt_error) — no hot-path cost.
  • Only the both-non-string branch where a list is involved changes. dict + num and other non-list mismatches keep the generic message; mixed str + X keeps the f-string hint (verified).
  • append and concat are 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.eigs EE20b pins the new prescriptive text (asserts the message names both append of and concat 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

InauguralPhysicist and others added 2 commits July 20, 2026 19:24
`[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>
@InauguralPhysicist
InauguralPhysicist merged commit 666770f into main Jul 21, 2026
18 checks passed
@InauguralPhysicist
InauguralPhysicist deleted the prescriptive-list-plus-error branch July 21, 2026 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make error messages prescriptive, not just diagnostic, at prior-divergence points

1 participant