Skip to content

Codegen: keyword binding, request contexts, array and numeric semantics, drawing collections, diagnostics - #327

Merged
luisleo526 merged 285 commits into
mainfrom
integrate/codegen-c1-1105
Nov 6, 2026
Merged

luisleo526 merged 285 commits into
mainfrom
integrate/codegen-c1-1105

Conversation

@luisleo526

@luisleo526 luisleo526 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Integrates a set of codegen changes across keyword binding, request contexts, collections, numeric values, drawing collections, and diagnostics.

  • Built-in calls bind keyword arguments to their own parameters or refuse unsupported forms.
  • Requested contexts preserve helper history, string results, persistent state, and dynamic timeframe behavior.
  • Arrays preserve missing-size and fill semantics, constructor argument order, and slice views.
  • Numeric values preserve integer na, quotient fractions, and runtime history-offset checks.
  • Drawing collections preserve aliases, loops, arena bounds, and handle equality.
  • Strategy and diagnostic behavior covers risk expressions, positive compile-time max_bars_back, and synchronized catalog pins.
  • Host members used by request emission remain reserved.

Validation

  • The tuple base reproduced five intended failures; the fix run passed 279 tests.
  • Array-size, host-member, and drawing controls reproduced three base failures; the fix run passed 130 tests with 25 private-fixture skips.
  • The preceding composition commit's suite collected 24,447 tests: 24,207 passed, 208 skipped, and 32 failed. Two diagnostic-note rows are fixed in this head; the other 30 report Missing Git identity because that archived engine input had no .git directory. Engine-free CI now skips native-only rows with explicit reasons; the paired gate runs them.
  • Final-head diagnostics passed 892 tests with 22 private-fixture skips and 0 failures; the paired native proof on engine #750 passed 158 tests with 0 skips across the numeric, public-value, and nested-request rows, including the Four valid request.security forms refused: lookahead from a variable, '' timeframe, [] on a requested value in a nested request, an uncalled wrapper #294 rows.
  • The helper-local varip rows use recorded release values; live-bar TradingView parity and a mutation substitution remain outside this validation.
  • All cited executions used the same paired engine build; the normal repository gates re-run the full matrix on the pushed head.
  • The native-input skip proof passed 45 tests and skipped 87 with explicit reasons when inputs were absent; the paired run passed with 0 skips.

Coverage limits

The full suite ran on the preceding composition; this head also carries the mainline timing-test retirement and native-input contract, so the final paired gate remeasures the exact head. Additional tuple traversal-arm coverage and the varip mutation discriminator remain follow-up checks.

🤖 Generated with Claude Code

luisleo526 and others added 30 commits November 3, 2026 23:37
… check

The array-history read, the request.security input-length getter and the method envelopes of two dynamic-offset rows now also check a negative history offset. Each moved pin expects exactly the text the generator emits, with the check where the generator puts it; the two hash pins carry the hashes of the new method text, and the only difference from the earlier text is that check.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…d constants

input.enum(OPT_FAST, "Mode", options = [OPT_FAST, OPT_SLOW]) with
`const Mode OPT_FAST = Mode.fast` lost its option list (empty options, setting
reported unsupported), while the same input written with Mode.fast directly
kept it. The options are now resolved through the same immutable-declaration
walk the default already used; a reassigned, var, later-declared, mixed-enum or
non-enum element keeps the unsupported descriptor. The direct form's emission
is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Validate keyword names against each strategy order function's declared
signature and preserve valid positional, named, and mixed calls.

Add regression coverage for diagnostics and native once-only behavior.
Preserve per-bar expression history, global tuple reads, string initialization,
array constructor keyword binding, and reassigned input declarations.

Add source-derived value regression cases and preservation controls.
Bind a late entry fill to its extra callback and independently check history
values at defaults and overrides. Require a marker-restore mutation to fail
by semantic values while retaining the Series restore.
Apply the owner's release CI reduction rule to the commit created by
release.yml. The explicitly dispatched release and downstream notify remain.
Combine the accepted member chains and the receiver-use integration fixture
on the current main base. Final composition review and the single batch gate
remain pending; additional members still require their admission conditions.
Add the accepted request/lookahead member including the catalog hint repair.
Final metadata union, composed review and the single batch gate remain due.
Record the receipt-backed fixed math parameter names and common argument
binding, refuse variadic math keywords, and catalog PF-E5089/PF-E5090 with
pins and exact diagnostic fixtures while preserving historical messages.

Part of #287. Local partial source checkpoint; direct Analyzer strategy
header folding still requires the admitted constant_fold seam repair.
Native RED/GREEN and Claude source/process acceptance remain pending.
Resolve Series selection through the typed common writer, keep the supported
default-quantity refusal, and retain both strategy string and float slots.
Final composed-hunk review and the single batch gate remain required.
Add the selected history-offset member without changing its constant and
non-negative behavior. Final rebase, composed review and combined gate remain.
Route registered math header keywords through the shared validator before
binding, preserving constant evaluation and located catalog diagnostics.
Add direct Analyzer header controls alongside the existing public paths.

Part of #287. Source checkpoint; identical focused RED/GREEN and Claude
acceptance remain pending before batch admission.
…eries argument bound to a simple parameter and for a keyword element in array.from

TradingView stops compiling a script that passes a series value to a function or method parameter declared simple or const, or that names an element of array.from; the generator accepted these scripts and ran them. The analyzer now compares the proven qualifier of each bound argument with the declared parameter qualifier in one place shared by functions and methods, and raises a located diagnostic for the two rules. Unknown expressions, qualifier-only overloads and imported v5 definitions keep their previous handling, and a script with a qualifier-correct argument translates to the C++ it had.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Keep numeric destination conversion while using missing quantity for omitted
order size. Preserve authored zero and the existing string and keyword fixes.
Final composed review, paired rebase and combined gate remain required.
Union the accepted diagnostic entries, pins and declared-addition handling.
Keep the existing lookahead migration and all prior changelog entries.
Keep every accepted catalog entry and pin, both declared-addition mechanisms,
the lookahead metadata migration and the numeric conversion contract.
Preserve existing changelog entries and the accepted enum option folding.
Final named tests, paired rebase and the single batch gate remain required.
Part of #293.

Add generic full-month formats beside the existing abbreviated-month parser
formats. Preserve independent calendar and boundary checks.

This local checkpoint retains all four unresolved native tuple-consumer
failures and their original expectations. It is not a completed acceptance
or publication claim; the independent native proof and required reviews
remain pending.
… copy shares its array fields

Records that stay within one bar hold their array fields through a handle. A field that is omitted in Type.new(), or given na, is now a missing array ID
(na(record.field) is true), distinct from a valid empty array, and using it as an array stops with the usual na-array error. Copying such a record with
Type.copy() is now accepted and shares the array fields with the original, as TradingView does, while scalar fields stay independent. Records kept across
bars still refuse the copy.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
session.regular and session.extended are constant strings in Pine, so passing one to a simple parameter is valid; the qualifier check ranked every session member as a series and refused it. The two names now rank as constants, the per-bar session flags stay series, and the controls compare the translated C++ of the valid forms with the previous version's.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Preserve actual diagnostic filenames, register named argument children
before analysis, and return math keyword errors before unrelated notes.
Configure the native quarter-tick fixture through the public engine setter.

The independent oracle and all assertions remain unchanged. Part of #287;
fresh identical-fixture RED/GREEN and Claude acceptance remain pending.
…fuses

The control assumed the previous version translates ticker.modify; it reports ticker.modify as unsupported, so there is no previous translation to compare with. The two session constants keep their controls.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
TradingView CE10236 requires a method body to use its first argument.
The exact unused-forward refusal is retained in receipt
sha256/a182f1b4dd8f2c5aa36169fd4bd25c77771d41dd5cb70f55376088f37e4055af.

Copy only the three reviewed receiver-use corrections from ce12d296.
Keep every existing assertion and require native execution by name on
the composed tree before acceptance; source correction is not a test pass.
luisleo526 and others added 13 commits November 6, 2026 03:55
Handle integral non-bool missing indices for floating arrays: get returns a
floating NA value and set performs no indexed write after evaluating its
operands. Preserve finite bounds, negative indexing, evaluation order and
journal behavior. Keep a bounded proven-finite constant path byte-compatible
with the existing checked emitter.

Add native input-derived coverage for the measured array case, evaluation and
journal controls, finite/error boundaries and the complete selector classes.
Two files conflicted, both in how timestamp(dateString) reads a date string.

pineforge_codegen/codegen/visit_call.py, _parse_pine_datestring_ms: the branch
had added full month names and kept the written sign of a zero-hour zone
(GMT-00:30) by reading the old two-group zone regex; main (#330) replaced that
regex and the zone arithmetic with the zone-word grammar that reads the sign,
hours and minutes separately and lets the last zone token decide. The merge
keeps the branch's full month names (the docstring wording and the %B formats
merged without conflict) and takes main's zone-word code, which already keeps
the written sign of a negative zone with a zero hour, so both behaviours hold.

CHANGELOG.md: both sides added entries under "Unreleased"; all of them are kept.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
After merging codegen main into this branch, four rows of
tests/test_timestamp_zero_hour_offset.py failed: UTC and GMT with +24:00 and
-24:00 were expected to keep raising ValueError. That error came from building
the zone word as a datetime.timezone, which refuses an offset of 24 hours or
more. Main replaced it (the zone-word change in #330): the offset is plain
arithmetic on the date fields, as in TradingView, whose exported trade lists
for UTC+24, GMT-24 and UTC+25 match that rule. So the rows now pin the value
instead of the old failure: the fields read as UTC minus the signed offset
(2024-01-01 00:00 +24:00 is 2023-12-31 00:00 UTC, -24:00 is 2024-01-02 00:00
UTC), with the expected fields written independently of the parser like the
rows above them.

The +-24:00 spelling is the same rule applied; the exported lists cover the
spellings UTC+24 and GMT-24.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
A non-constant array.get index now emits the na-aware getter that matches
TradingView (get with an na index returns na), so this shape's generated
C++ intentionally differs from the older reference. Its behaviour is covered
by the native na-index rows; the other twelve shapes keep their byte-for-byte
comparison.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Restore unbounded generated drawing arenas while the bounded implementation is
profiled and repaired separately. Keep the existing collector behavior and
remove the emission assertions that require the bounded construction.
@luisleo526
luisleo526 merged commit 08261a2 into main Nov 6, 2026
5 of 9 checks passed
luisleo526 added a commit that referenced this pull request Nov 6, 2026
Brings the integration of the pending compiler fixes (#327) into this branch.
The only conflict is CHANGELOG.md, where both sides add entries at the top of
the Unreleased section: both are kept, this change's entry first. The code and
the tests merge without a conflict, including tests/test_calendar_lambda_locals.py
and tests/test_codegen_audit_fixes.py, which both sides edit.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
luisleo526 added a commit that referenced this pull request Nov 6, 2026
Restores test coverage for the declared drawing-count refusal (`PF-E0036`) after the bounded drawing arenas were reverted in #327, which removed `tests/test_drawing_arena_bounds.py` with them. The refusal code itself was not changed.

The file holds only rows that do not depend on the arena text:

- a declared `max_lines_count` / `max_boxes_count` / `max_labels_count` above 2147483642 is refused at its literal with `PF-E0036` (exact message, line and column);
- the largest accepted value, 2147483642, still translates;
- an oversized count in a script that draws nothing is not refused and emits no drawing arena.

Test-only; no generated C++ changes. `tests/test_drawing_arena_bounds.py`: 21 passed on Linux aarch64.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
luisleo526 added a commit that referenced this pull request Nov 7, 2026
The Unreleased section lists the keyword-argument and allow_entry_in fixes of
#327 but not three other changes it made. Add them:

- a var array with a non-empty initializer declared inside an if block is
  initialized when the declaration is first reached (#333);
- strategy.risk.max_drawdown() and strategy.risk.max_intraday_loss() called
  with type = strategy.percent_of_equity, or with that constant held in a
  variable, apply the percentage limit like the positional form (#325, #326);
- max_bars_back() with a const int depth keeps that depth (#326).

Each form was run next to its control (the positional or literal form, or the
same var declared at the top level) on the released 1.10.0 and on main: every
form listed here differs from its control on 1.10.0 and equals it on main.
Documentation only; CHANGELOG.md is the only file changed.

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant