Report error for task.hash/task.workDir in process script section#159
Open
bentsherman wants to merge 2 commits into
Open
Report error for task.hash/task.workDir in process script section#159bentsherman wants to merge 2 commits into
bentsherman wants to merge 2 commits into
Conversation
The implicit `task` variable exposes properties such as `task.hash` and `task.workDir` that depend on the task hash, which in turn is derived from the process script. Using these properties in the `script:` (or `stub:`) section therefore creates a circular dependency. Add a rule in TypeCheckingVisitorEx that reports a type error for each use of `task.hash` or `task.workDir` in the script and stub sections. The `exec:` section is exempt since it does not contribute to the command hash in the same way. Signed-off-by: Ben Sherman <bentshermann@gmail.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
The implicit
taskvariable in a process exposes properties such astask.hashandtask.workDirthat depend on the task hash, which in turn is derived from the process script. Using these properties in thescript:(orstub:) section therefore creates a circular dependency.This PR adds a rule in
TypeCheckingVisitorExthat reports a type error for each use oftask.hashortask.workDirin the script and stub sections.Details
TaskScriptPropertyVisitorinner class walks the script/stub body and flags anyPropertyExpressionwhose property ishash/workDirand whose receiver resolves toTaskConfig(so detection is type-based, not just name-based).script:/shell:(node.execwhennode.type != "exec") andstub:(node.stub).exec:section is exempt, since it does not contribute to the command hash in the same way.Tests
Added cases to
TypeCheckingTest:task.hashandtask.workDirin thescript:sectiontask.hashandtask.workDirin thestub:sectiontask.cpus,task.process,task.attempt) are still allowedtask.hash/task.workDirare allowed in theexec:section🤖 Generated with Claude Code