Preserve grouping and typing in TA reset length lowering#41
Merged
Conversation
The stable-runtime-TA-length reset path re-materialized length-defining expressions through a lossy AST->infix serializer: BinOp/UnaryOp operands were joined without grouping parentheses and without the analyzer's numeric coercions, so C++ operator precedence re-associated the expression and int/int division truncated. A derived length like 2 / (-(beta) + sqrt(beta*beta + 2*beta)) could collapse through sqrt(negative) -> NaN -> max(1, int(round(NaN))) to a constant length 1, silently degrading every TA instance built from it. Fix: parenthesize non-atomic operands in both serializers so the expanded expression re-parses to the same tree, then lower the reset expression through the same expression visitor used for scalar statements, making grouping and Pine numeric typing (always-float division, (double) coercions) correct by construction. Input-backed variables render as override-aware get_input_*() reads in reset context because resets can run before input members are initialized. The legacy token-substitution renderer remains only as a fallback. Adds regressions for grouping-across-division and float division of two int operands in derived lengths. Co-Authored-By: Claude Fable 5 <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
Validation
🤖 Generated with Claude Code