fix(amend): evaluate first arg; in-place amends return the symbol#257
Merged
Conversation
insert/upsert decided in-place vs functional by inspecting the raw parse node for a literal 'sym (ATTR_QUOTED), so only a literal first arg drove in-place mode. A symbol arriving any other way — through a variable, via (quote t), or as a lambda parameter — fell through to the vec/list path and raised `type`. Unify all amends on one rule (already followed by update/alter): evaluate the first argument; a symbol value names a global to amend in place, a table/vec value is amended functionally. In-place amends now return the symbol rather than the amended clone, matching v1. - query.c: insert/upsert mirror update's eval-first dispatch; drop the ATTR_QUOTED raw-node special case. In-place returns the symbol across insert/upsert/update. - tblop.c: alter in-place returns the symbol. - tests: new insert_inplace_symbol.rfl regression (variable/quote/lambda forms, symbol return); update existing tests that relied on the old value return, including the (set x (alter 'x ...)) idiom. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Problem
insert/upsertdecided in-place vs functional by inspecting the raw parse node for a literal'sym(theATTR_QUOTEDflag), so only a literal first arg drove in-place mode. A symbol arriving any other way raisederror: type:updateandalteralready did the right thing (evaluate the first arg, resolve a symbol to its named global).Fix
Unify all amends on one rule: evaluate the first argument; a symbol value names a global to amend in place, a table/vec value is amended functionally. In-place amends now return the symbol rather than the amended clone (matching v1).
query.c—insert/upsertmirrorupdate's eval-first dispatch; dropped theATTR_QUOTEDraw-node special case. In-place returns the symbol acrossinsert/upsert/update. (The internalupsert→insertrecursion via the already-evaluated table path is untouched.)tblop.c—alterin-place returns the symbol.This works through variables,
(quote t), and lambda parameters, since everything now routes throughray_env_get/ray_env_setlike the literal'sympath always did.Tests
test/rfl/table/insert_inplace_symbol.rfl(variable/quote/lambda forms, functional-vs-in-place, symbol return value acrossinsert/upsert/update/alter).update.rfl,query_coverage.rfl,linkop/coverage.rfl,test_lang.c), including the(set x (alter 'x ...))idiom which now uses the in-place mutation directly.Full suite passes under the sanitizer build (3441 passed, 0 failed, 3 pre-existing skips).
🤖 Generated with Claude Code