Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions shortcutgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,16 @@ func variableValue(variable varValue) map[string]any {
if variable.valueType == Variable && variableReference.valueType != "" {
refValueType = variableReference.valueType
}
// A reference to an action's output has value type Action, not Dict, so
// resolve what the action actually returns. Without this a key access on
// a dictionary-returning action (e.g. getDictionary()) compiles to a
// property lookup, which Shortcuts resolves to an empty value at
// runtime. makeAggrandizement() already does this for inline references.
if refValueType == Action {
if variableAction, ok := variableReference.value.(action); ok && variableAction.def != nil {
refValueType = variableAction.def.outputType
}
}
if refValueType == Dict {
aggrandizements = append(aggrandizements, map[string]any{
"Type": "WFDictionaryValueVariableAggrandizement",
Expand Down
19 changes: 19 additions & 0 deletions tests/dictionary-action-output.cherri
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Subscripting a dictionary that is the output of an action (e.g. getDictionary())
must compile to a dictionary-value aggrandizement (Type: WFDictionaryValueVariableAggrandizement),
the same as subscripting a literal dictionary — not a property aggrandizement,
which resolves to nothing at runtime.
*/

#include 'actions/scripting'

@response = "placeholder"
const responseDict = getDictionary(@response)

// bare subscript on an action-output dictionary
@summary = responseDict['summary']

// subscript inside string interpolation (was already correct)
const inline = "{responseDict['summary']}"

alert("bare: {summary} inline: {inline}", "Dictionary action output")