Skip to content

Conversation

@trulede
Copy link
Contributor

@trulede trulede commented Sep 12, 2025

A deferred task was recalculating vars which results in re-evaluation of templated and sh vars. This might not be desired in the case where values change with each evaluation; e.g. template function randInt.

This PR passes the task Vars to the deferred task, and removes the code which previously re-evaluated the vars. This works and I do not notice any point in the code where the task Vars would be mutilated (changed) so I did not use the DeepCopy() function of the Vars object when calling runDeferred(). I think this will be OK, but I would still review that part again.

fixes #2244

@andreynering andreynering added the area: variables Changes related to variables. label Nov 11, 2025
Copy link
Member

@andreynering andreynering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This simply makes total sense. Thank you @trulede!

@andreynering andreynering merged commit 0052ad2 into go-task:main Nov 11, 2025
13 checks passed
andreynering added a commit that referenced this pull request Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: variables Changes related to variables.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variable definitions are re-evaluated in deferred cmds

2 participants