fix(codegen): declare loop-local drawing-object handles (line/label/box)#24
Merged
Merged
Conversation
A variable assigned from a skipped visual call (line.new / label.new / box.new
/ ...) was only declared when the namespace was `table` (SKIP_VAR_TYPES); for
other drawing namespaces the declaration was dropped. In script/if scope the var
is a class member (declared anyway), but as a *for-loop local* it became
undeclared, so e.g.
ln = line.new(...)
array.push(aoLines, ln)
emitted `aoLines.push_back(ln);` with no `ln` -> "use of undeclared identifier
'ln'". Common in webhook/DCA strategies that draw AO level lines in a loop.
Always emit a default-valued local declaration for skip-expr assignments — the
value is inert (drawing ops have no backtest effect) but references must compile.
Removes the now-unused SKIP_VAR_TYPES import.
Adds regression tests. No corpus regression: all 258 corpus probes transpile
byte-identically with vs without this change.
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.
Problem
A variable assigned from a skipped visual call (
line.new/label.new/box.new/ …) was declared only when the namespace wastable(SKIP_VAR_TYPES). For the other drawing namespaces the declaration was dropped. In script/ifscope the var is a class member (declared anyway), but as a for-loop local it became undeclared:Found running real-world strategies through the engine — common in webhook/DCA bots that draw AO level lines in a loop (11 strategies in the test set hit this).
Fix
Always emit a default-valued local declaration for skip-expr assignments. The value is inert (drawing ops have no backtest effect) but references must compile. Removes the now-unused
SKIP_VAR_TYPESimport.Tests / regression
tests/test_codegen_drawing_handles.py(line + label handles in a loop).🤖 Generated with Claude Code