Skip to content

fix: bare dictionary subscript on action output compiled to Property aggrandizement - #2

Open
BTForIT wants to merge 1 commit into
feat/filterContacts-sortfrom
fix/dict-key-aggrandizement-on-action-output
Open

fix: bare dictionary subscript on action output compiled to Property aggrandizement#2
BTForIT wants to merge 1 commit into
feat/filterContacts-sortfrom
fix/dict-key-aggrandizement-on-action-output

Conversation

@BTForIT

@BTForIT BTForIT commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Bug

A bare dictionary subscript on an action-output variable compiles to the wrong aggrandizement type:

#include 'actions/scripting'
@resp = "..."
const respDict = getDictionary(@resp)

@summary = respDict['summary']        // BUG: WFPropertyVariableAggrandizement → empty at runtime
const s = "{respDict['summary']}"     // OK:  WFDictionaryValueVariableAggrandizement

variableValue() only emits WFDictionaryValueVariableAggrandizement when the referenced variable's value type is Dict. A variable holding an action's output has value type Action, so the subscript falls through to WFPropertyVariableAggrandizement — 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 because makeAggrandizement() resolves Action references through the action definition's outputType.

Hit in production: a shortcut that read Resp['status'] after a downloadURL() POST branched to its failure alert on every successful run.

Fix

shortcutgen.go variableValue(): when the reference's value type is Action, resolve it to the action definition's outputType before the Dict check — the same resolution makeAggrandizement() already performs. +10 lines.

Verification

  • New fixture tests/dictionary-action-output.cherri (bare + inline subscript on getDictionary() output). Before: bare case emitted 1 WFPropertyVariableAggrandizement. After: both emit WFDictionaryValueVariableAggrandizement (2/0).
  • Differential compile of every existing tests/*.cherri fixture with baseline vs fixed binaries: zero regressions; all byte-level differences reproduce between two baseline runs as well (UUID nondeterminism only).
  • On-device: the runtime behavior of both aggrandizement types was confirmed on a real device — the Property form yields an empty value on a dictionary, the DictionaryKey form resolves the key. (The affected production shortcut was patched by moving the subscripts into string interpolation, which compiles to the DictionaryKey form.)
  • go test -vet=off ./... fails identically on the base branch (Duplicate enumeration 'backgroundSound' — the test harness's resetParser() doesn't clear enum state between fixtures, and go vet separately flags a pre-existing unused slices.Delete result in actions_std.go:817). Neither is introduced or affected by this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PmFsHCZ4S5KAiUCu4uZAtH

…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
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.

1 participant