Fix Edit Lambda for calls with omitted arguments#174
Open
jimmytacks wants to merge 1 commit into
Open
Conversation
When the LAMBDA call provided fewer args than the LAMBDA declared, the generated LET referenced free parameter names (e.g. `chunk_size`, `horizontal` inside EXPLODE's body) and was invalid. Bind each omitted parameter at the top of the LET to a default extracted from the canonical `IF(ISOMITTED(p), default, p)` wrapper in the body, then strip the wrapper to a bare `p` so the LET round-trips cleanly through LET to LAMBDA. When no pattern is detected, fall back to `""` as a visible placeholder. Drop the no-op `p, p` shadow that the spec-0002 LetToLambdaBuilder leaves behind after the wrapper is removed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4a97d60 to
a8d8a6b
Compare
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.
Closes #151.
Summary
When Edit Lambda expanded a call like
=EXPLODE(A1)where the LAMBDA declared more parameters (text,[chunk_size],[horizontal]) than the caller supplied, the omitted parameters were left as free references inside the body — making the generated LET invalid.The fix:
IF(ISOMITTED(p), default, p)wrapper anywhere in the LAMBDA body for each omitted parameterp. Extractdefaultand bindp, defaultat the top of the LET. Replace the IF wrapper with a barepso the LET stays clean and round-trips through LET to LAMBDA without re-adding the wrapper unless the user re-checks "Optional".p, ""so the LET is at least valid and the hole is visible to the author.ISOMITTED(p)references not wrapped in the IF pattern (e.g.Help?, ISOMITTED(text)) are left alone — when the param is provided in the call,ISOMITTEDevaluates to FALSE on the bound name, which is the right semantics.LetToLambdaBuilderwraps optional params as a LET binding named after the param (e.g.y, IF(ISOMITTED(y), 10, y)). After stripping, that becomesy, y— a no-op shadow of the outer binding. Drop those during flattening to keep the output clean.Test plan
dotnet build addin/lambda-boss.slnxclean (0 errors)dotnet test addin/lambda-boss.Tests/lambda-boss.Tests.csproj— 827/827 passingy, yshadow dropped, and missing-arg fallback to"".=EXPLODE(A1)then run /Edit Lambda — the produced LET should bindchunk_size, 1andhorizontal, FALSEwith the IF wrappers stripped from_size/_horiz.🤖 Generated with Claude Code