Skip to content

Commit 356a149

Browse files
fix not - invoked closures
1 parent af56d45 commit 356a149

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

contrib/tools/workflowcheck/determinism/checker.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,11 @@ func containsAnonAssignToVar(node ast.Node, obj types.Object, callPos token.Pos,
516516
if found || n == nil || n.Pos() >= callPos {
517517
return false
518518
}
519+
// Don't descend into function literals — assignments inside closures
520+
// that are only defined (not invoked) should not count.
521+
if _, ok := n.(*ast.FuncLit); ok {
522+
return false
523+
}
519524
if assign, ok := n.(*ast.AssignStmt); ok {
520525
for i, lhs := range assign.Lhs {
521526
if lhsIdent, ok := lhs.(*ast.Ident); ok && info.ObjectOf(lhsIdent) == obj && i < len(assign.Rhs) {

contrib/tools/workflowcheck/workflow/testdata/src/a/workflow.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ func WorkflowLocalActivityIfElseOverridden(ctx workflow.Context) error {
138138
return nil
139139
}
140140

141+
func WorkflowLocalActivityAnonInClosure(ctx workflow.Context) error {
142+
f := myLocalActivity
143+
_ = func() {
144+
f = func(ctx context.Context) error { return nil }
145+
_ = f
146+
}
147+
workflow.ExecuteLocalActivity(ctx, f)
148+
return nil
149+
}
150+
141151
func WorkflowLocalActivityFuncParam(ctx workflow.Context, f func(ctx context.Context) error) error {
142152
workflow.ExecuteLocalActivity(ctx, f)
143153
return nil

0 commit comments

Comments
 (0)