fix: bare dictionary subscript on action output compiled to Property aggrandizement - #2
Open
BTForIT wants to merge 1 commit into
Open
Conversation
…aggrandizement variableValue() only emitted a WFDictionaryValueVariableAggrandizement when the referenced variable's value type was Dict. A variable holding an action's output (e.g. `const d = getDictionary(x)`) has value type Action, so `@v = d['key']` fell through to WFPropertyVariableAggrandizement — which Shortcuts resolves to an empty value at runtime. The same subscript inside string interpolation was already handled correctly by makeAggrandizement(), which resolves Action references via the action definition's outputType. Apply the same resolution in variableValue(): when the reference is an Action, use its definition's outputType before the Dict check. Adds tests/dictionary-action-output.cherri covering bare and inline subscripts on an action-output dictionary (baseline compiled the bare case to 1 Property aggrandizement; now both compile to DictionaryKey). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PmFsHCZ4S5KAiUCu4uZAtH
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.
Bug
A bare dictionary subscript on an action-output variable compiles to the wrong aggrandizement type:
variableValue()only emitsWFDictionaryValueVariableAggrandizementwhen the referenced variable's value type isDict. A variable holding an action's output has value typeAction, so the subscript falls through toWFPropertyVariableAggrandizement— which Shortcuts resolves to an empty value at runtime (a dictionary has no such content-item property). The identical subscript inside string interpolation was already correct becausemakeAggrandizement()resolvesActionreferences through the action definition'soutputType.Hit in production: a shortcut that read
Resp['status']after adownloadURL()POST branched to its failure alert on every successful run.Fix
shortcutgen.govariableValue(): when the reference's value type isAction, resolve it to the action definition'soutputTypebefore theDictcheck — the same resolutionmakeAggrandizement()already performs. +10 lines.Verification
tests/dictionary-action-output.cherri(bare + inline subscript ongetDictionary()output). Before: bare case emitted 1WFPropertyVariableAggrandizement. After: both emitWFDictionaryValueVariableAggrandizement(2/0).tests/*.cherrifixture with baseline vs fixed binaries: zero regressions; all byte-level differences reproduce between two baseline runs as well (UUID nondeterminism only).go test -vet=off ./...fails identically on the base branch (Duplicate enumeration 'backgroundSound'— the test harness'sresetParser()doesn't clear enum state between fixtures, andgo vetseparately flags a pre-existing unusedslices.Deleteresult inactions_std.go:817). Neither is introduced or affected by this change.🤖 Generated with Claude Code
https://claude.ai/code/session_01PmFsHCZ4S5KAiUCu4uZAtH