pineforge-codegen 1.11.0__tar.gz → 1.13.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/CHANGELOG.md +187 -5
  2. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/PKG-INFO +1 -1
  3. pineforge_codegen-1.13.0/VERSION +1 -0
  4. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/docs/ci.md +6 -0
  5. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/docs/codegen-coverage-gaps.md +1 -1
  6. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/docs/reference/file-map.md +6 -0
  7. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/docs/reference/known-codegen-quirks.md +5 -2
  8. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/docs/reference/support-contracts.md +51 -3
  9. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/analyzer/base.py +864 -91
  10. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/analyzer/call_handlers.py +157 -58
  11. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/analyzer/callable_history_names.py +118 -16
  12. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/analyzer/contracts.py +6 -0
  13. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/analyzer/operators.py +3 -1
  14. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/analyzer/types.py +263 -14
  15. pineforge_codegen-1.13.0/pineforge_codegen/analyzer/v6_forms.py +116 -0
  16. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/analyzer/value_bindings.py +6 -1
  17. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/block_locals.py +56 -20
  18. pineforge_codegen-1.13.0/pineforge_codegen/builtin_constants.py +85 -0
  19. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/base.py +325 -67
  20. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/checked_settings.py +12 -14
  21. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/constant_values.py +79 -6
  22. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/drawing.py +113 -26
  23. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/emit_top.py +144 -20
  24. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/helpers.py +95 -8
  25. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/input.py +33 -1
  26. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/order_shapes.py +2 -1
  27. pineforge_codegen-1.13.0/pineforge_codegen/codegen/retained_alias.py +315 -0
  28. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/run_stops.py +10 -0
  29. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/security.py +298 -49
  30. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/strategy_declaration.py +6 -2
  31. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/ta.py +14 -9
  32. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/tables.py +146 -41
  33. pineforge_codegen-1.13.0/pineforge_codegen/codegen/tv_string_units.py +122 -0
  34. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/types.py +105 -19
  35. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/visit_call.py +142 -50
  36. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/visit_expr.py +41 -19
  37. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/visit_stmt.py +22 -10
  38. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/diagnostic_codes.py +31 -3
  39. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/diagnostics_catalog.json +9 -1
  40. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/function_overloads.py +1 -0
  41. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/lexer.py +14 -2
  42. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/method_binding.py +7 -0
  43. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/parser.py +35 -5
  44. pineforge_codegen-1.13.0/pineforge_codegen/reference_casts.py +38 -0
  45. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/signatures.py +106 -23
  46. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/support_checker.py +2 -0
  47. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/symbols.py +26 -0
  48. pineforge_codegen-1.11.0/VERSION +0 -1
  49. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/.gitignore +0 -0
  50. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/CONTRIBUTING.md +0 -0
  51. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/LEGAL.md +0 -0
  52. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/LICENSE +0 -0
  53. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/README.md +0 -0
  54. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/docs/PUBLIC_CONTRACT.md +0 -0
  55. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/docs/engine-main-ci.md +0 -0
  56. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/docs/pine-cap-activation.md +0 -0
  57. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/docs/reference/adding-a-pine-function.md +0 -0
  58. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/docs/reference/conventions.md +0 -0
  59. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/docs/reference/pipeline.md +0 -0
  60. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/__init__.py +0 -0
  61. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/analyzer/__init__.py +0 -0
  62. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/analyzer/diagnostics.py +0 -0
  63. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/analyzer/qualifiers.py +0 -0
  64. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/analyzer/tables.py +0 -0
  65. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/array_binding.py +0 -0
  66. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/ast_nodes.py +0 -0
  67. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/builtin_keywords.py +0 -0
  68. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/__init__.py +0 -0
  69. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/array_field_width.py +0 -0
  70. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/array_slice.py +0 -0
  71. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/ascii.py +0 -0
  72. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/bool_text.py +0 -0
  73. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/capabilities.py +0 -0
  74. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/capacities.py +0 -0
  75. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/closed_trade_fold.py +0 -0
  76. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/collection_history.py +0 -0
  77. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/color_constants.py +0 -0
  78. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/constant_fold.py +0 -0
  79. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/endless_for.py +0 -0
  80. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/for_loops.py +0 -0
  81. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/graph_journal.py +0 -0
  82. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/helpers_syminfo.py +0 -0
  83. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/history_sharing.py +0 -0
  84. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/host_members.py +0 -0
  85. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/id_sites.py +0 -0
  86. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/session_market.py +0 -0
  87. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/timeframe_values.py +0 -0
  88. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/codegen/tv_number_format.py +0 -0
  89. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/collection_history.py +0 -0
  90. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/cpp_allowlist.py +0 -0
  91. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/cpp_names.py +0 -0
  92. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/drawing_all.py +0 -0
  93. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/errors.py +0 -0
  94. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/external_requests.py +0 -0
  95. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/finite_ta_length.py +0 -0
  96. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/input_keys.py +0 -0
  97. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/intrinsic_binding.py +0 -0
  98. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/library_inline.py +0 -0
  99. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/library_modules.py +0 -0
  100. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/library_v5.py +0 -0
  101. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/limits.py +0 -0
  102. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/loop_types.py +0 -0
  103. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/matrix_overloads.py +0 -0
  104. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/pine_libraries.py +0 -0
  105. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/pine_spelling.py +0 -0
  106. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/pragmas.py +0 -0
  107. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/request_discovery.py +0 -0
  108. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/request_feed_inventory.py +0 -0
  109. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/security_contexts.py +0 -0
  110. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/session_reads.py +0 -0
  111. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/timeframe_token_cli.py +0 -0
  112. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/tokens.py +0 -0
  113. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pineforge_codegen/tv_input_choices.py +0 -0
  114. {pineforge_codegen-1.11.0 → pineforge_codegen-1.13.0}/pyproject.toml +0 -0
@@ -22,6 +22,182 @@ supported as exact pairs; on the 0.x line they are independent. See the
22
22
 
23
23
  ## Unreleased (next release)
24
24
 
25
+ - Strategy sizing constants retain their string values in expressions, aliases
26
+ and helper calls. Host order and risk settings convert these values to their
27
+ numeric representation only at the setting boundary.
28
+
29
+ - `timeframe.in_seconds` and `timeframe.change` resolve an evaluated empty
30
+ string to the chart period, including input, variable, function-return and
31
+ named arguments. The argument is evaluated once, and nonempty strings keep
32
+ their explicit period. Bare `na` remains accepted; the value returned by
33
+ `timeframe.change(na)` is still awaiting verification against TradingView.
34
+ Non-string timeframe arguments are refused before C++ emission with the
35
+ stable `PF-E2095` type diagnostic and a source location, including input
36
+ values, reassignments, indicator results and helper parameters. Equally
37
+ specific diagnostic templates distinguish primitive types from qualifiers
38
+ using their catalog argument kinds. Dotted builtin signatures retain supplied
39
+ arguments, including escaped string literals and VWAP anchors. (#394)
40
+ - Script identifiers spelled like integer-to-float conversion temporaries,
41
+ including the underscore suffixes of nested conversions, now use the
42
+ generator's reserved-name escaping.
43
+ - Reference-typed UDT fields keep their type when initialized or reassigned
44
+ with `na`, including array defaults. Drawing handles cross user-function
45
+ and tuple boundaries by value, and `label(na)` produces a missing label
46
+ handle. Polyline locals, arrays, fields and delete methods retain opaque
47
+ handles and argument evaluation while rendering remains a visual no-op.
48
+ - Generated function variants and persistent local copies avoid authored and
49
+ generated member names, including names ending in `_cs1` and composed names
50
+ that overlap collection-history or requested-context storage. Persistent
51
+ declarations in sibling blocks also retain distinct storage when a script
52
+ uses their generated spelling. Declarations, calls and history storage use
53
+ the same allocated identities, including when selecting reachable variants
54
+ for emission. Regenerate C++ and relink affected strategies.
55
+ - Persistent declarations accept a type qualifier after `var` or `varip`.
56
+ Lower-timeframe requests return independently typed arrays for inline and
57
+ helper-returned tuple payloads.
58
+ - Complete nested indentation levels can combine tabs and spaces. Requested
59
+ `na`/`nz` helper parameters retain their bindings beside time operations;
60
+ global tuple declarations and their member histories share one requested
61
+ sample. Uncalled forwarding helpers no longer allocate unresolved TA buffers
62
+ for their unreachable call variants (#372). Bare tuple-element history
63
+ payloads retain their located refusal. Tuple histories rendered through the
64
+ expression visitor, including reads through globals, retain their chart
65
+ series and warning. Resolvable variants of a reachable helper retain their
66
+ TA state even when registered through an uncalled caller. Requested builtin
67
+ tuples reuse their existing sampled results, and mixed-clock tuple history
68
+ uses the registered history diagnostic.
69
+
70
+ - Built-in size, position, line/label style and shape constants retain their
71
+ string values in variables, selections, function arguments and returns, and
72
+ string input defaults/options. This fixes ambiguous C++ assignments, NUL
73
+ strings, unsupported size inputs and null-pointer string construction (#389).
74
+ Sort-order constants retain their distinct `sort_order` identity through
75
+ defaults and comparisons; invalid string conversions are diagnosed at their
76
+ Pine location, including individual elements of string input options.
77
+ `array.sort_indices` honors a supplied sort direction.
78
+ Scalar function overloads no longer crash during type checking.
79
+ Regenerate C++ and relink affected strategies.
80
+ - A zone name the engine rejects now makes calendar-form `timestamp()` stop the
81
+ run at its first evaluation, instead of silently calculating a UTC value.
82
+ The paired engine reports a typed timezone error identifying the failed bar.
83
+ An engine without the typed helper prints the text without the bar prefix, an
84
+ arm that paired releases do not meet. Accepted zones and UTC are unchanged;
85
+ the single `TIMESTAMP_REJECTED_ZONE_STOPS_RUN` switch restores the old behavior
86
+ (the compatibility macros stay in the output of a script that calls
87
+ `timestamp()` with a calendar). Not covered: the unchecked
88
+ `setenv("TZ", ...)` of the sealed branch and the restoring `setenv` or `unsetenv`
89
+ in the same lambda; on ENOMEM the environment stays unchanged and the conversion
90
+ silently uses the previous zone.
91
+ Setting the switch to `False` restores behavior, not the original emitted
92
+ bytes: the timezone macro block and newly reserved names remain.
93
+ Regenerate C++ and relink affected strategies.
94
+
95
+ - User functions retain array, object and string result types through branch
96
+ returns and history clones. Untyped arguments retain collection element
97
+ types through nested calls and tuple bindings, and reassigned matrix locals
98
+ keep their initializer's matrix type. (#391)
99
+ - Deeply nested user-function calls share type-inference work within each
100
+ expression query, including when a return type remains unresolved.
101
+ - `array.sort_indices` returns integer indices, accepts typed `array<int>`
102
+ results and honors ascending/default or descending order in namespace and
103
+ method calls, including named arguments. Numeric `na` values sort last in
104
+ ascending order and first in descending order; string arrays use lexical
105
+ ordering. The source array is unchanged. (#392)
106
+ - `request.security` keeps the requested-bar history and declaration-time
107
+ value of top-level scalar copies of persistent or reassigned globals,
108
+ including copy chains. A declared float copy preserves an integer source's
109
+ missing value, and replayed updates use the requested `bar_index`.
110
+ Compound assignments in requested selections retain the lexical binding
111
+ of their target and its request-owned `var` or `varip` storage.
112
+ See [#393](https://github.com/pineforge-4pass/pineforge-codegen-oss/issues/393).
113
+
114
+ ## 1.12.0 — 2026-11-12
115
+
116
+ - Pine v6 reports located errors for a missing `color.new` transparency,
117
+ `fill(transp=...)`, calendar-number timestamp defaults in `input.time` with
118
+ a time zone string as the first timestamp argument or a `timezone` keyword,
119
+ literal plot widths below one, and variable or function declarations named
120
+ `range`.
121
+ - `input.string`, `input.timeframe`, `input.symbol`, `input.session` and
122
+ `input.text_area` carry never-reassigned global string literals into defaults
123
+ and options, including var declarations; an unproven variable default is now
124
+ a located error instead of a silent empty default, while an option that
125
+ cannot be proven keeps the existing unsupported marker in the manifest.
126
+ - Untyped history parameters now infer the enclosing call's primitive type
127
+ through immutable plain locals, fixed-result builtins and user-call variants
128
+ whose result the callee body proves, to the same type family as an explicit
129
+ parameter declaration.
130
+ - Pine v6 now refuses an `if` or `while` condition whose numeric value comes
131
+ from a `ta.*` call or a built-in variable such as `strategy.position_size`,
132
+ as TradingView does. Use a comparison such as `ta.change(t) != 0` for a bool
133
+ condition. Bool overloads and Pine v5 libraries keep their existing behavior. (#361)
134
+ - A Pine string literal that holds a NUL now keeps its whole length. Codegen
135
+ built every string literal with `std::string("...")`, which is made from a C
136
+ string and ends at the first NUL, so "a", NUL, "b" had length 1 (TradingView
137
+ gives 3), equalled its own one-letter prefix, and two literals that differed
138
+ only after the NUL compared equal. A literal with a NUL is now built with the
139
+ number of bytes it stands for; a literal without one is spelled as before, so
140
+ the generated code of every other script is unchanged. Not covered, and still
141
+ cut at the first NUL as before: the default and the options of the string
142
+ inputs (`input.string`, `input.symbol`, `input.session`, `input.timeframe`,
143
+ `input.text_area`), which the settings receipt and the manifest equal, an
144
+ input title, and the timeframe and footprint-column literals. One comparison
145
+ changes with it: a string input whose default holds a NUL no longer equals
146
+ the literal it was given, because the default is cut and the literal is not
147
+ (the two were equal before only because both were cut). A `var` that is read
148
+ with history and starts from a literal with a NUL was refused (its first
149
+ value put the NUL byte itself into the generated code); it now translates
150
+ and keeps the whole literal.
151
+ - Direct retained record fields built from stable `var` arrays, and direct
152
+ plain `var` array aliases, stay live through their creation bar and then
153
+ keep their own copy of the array as it stood at the end of that bar; two
154
+ holders built from one array do not share it. `copy()` of such a record
155
+ keeps its existing compile error. Requested evaluations, collection
156
+ history, nested records and intrabar recalculations keep their previous
157
+ lowering. Regenerate C++ and relink affected strategies.
158
+ - `str.split(source, "")` with an empty separator now returns one part per
159
+ UTF-16 unit, as TradingView does: "axb" gives three parts, an accent or a CJK
160
+ character between two letters three, an emoji between two letters four (an
161
+ emoji is a high and a low surrogate, each kept as its own three-byte part).
162
+ It returned the whole string as one part, even for plain ASCII. The empty
163
+ text still has one part, as in TradingView. A separator that is not empty
164
+ splits as before, through the engine.
165
+ - A script variable spelled like one of the generator's tuple element bindings (`_tuple_result_0_elem_0`) now gets a private name instead of redeclaring the binding.
166
+ - A local declared in a function or method and spelled like a built-in variable now keeps its own type, history storage and reads. Exceptions: a string local spelled like a price field (`open`, `high`, `low`, `close`, `hl2`, `hlc3`, `hlcc4`, `ohlc4`, `volume`) that is read with history in a function requested through `request.security` is still refused, as before; the support check still warns that `bar_index`, `last_bar_index` and `timenow` diverge from TradingView at every read of a local with that name; a script that declares the same built-in name in several callable shapes is accepted where an ordinary name is refused by the shared-Series check; and the confirmed-bar request receipt of a request inside the declaring function names the local by its internal storage spelling.
167
+ - A function-local string read with history now keeps its string type in concatenations, so the emitted C++ joins the current and previous values without applying `std::to_string` to a string (#354).
168
+ - A function or method parameter spelled like a built-in variable (`close`,
169
+ `high`, ...) now keeps its `[n]` history operator and gives the same values
170
+ as when the parameter has another name (#360).
171
+ - A `var` declared in one block no longer shares storage with a plain variable
172
+ of the same name in a sibling block, so it keeps its value across runs (#359).
173
+ - A float setting of a built-in indicator computed from an input now keeps
174
+ its fraction, as on TradingView: the multiplier of `ta.bb`, `ta.bbw`,
175
+ `ta.kc`, `ta.kcw` and the `ta.vwap` bands, the factor of `ta.supertrend`,
176
+ the arguments of `ta.sar`, and the offset and sigma of `ta.alma` (#362).
177
+ Regenerate C++ and relink affected strategies.
178
+ - `str.length`, `str.pos` and `str.substring` now count and cut text in UTF-16
179
+ code units, as TradingView does: an emoji is two units and every other
180
+ character one. They counted UTF-8 bytes, so an accent counted 2, a CJK
181
+ character 3 and an emoji 4, and a position or a cut after such a character
182
+ was off by the extra bytes. The helpers are emitted into the generated file
183
+ only when its code calls one of the three functions (a call that is only a
184
+ plot argument emits nothing), so every other script keeps the text it had;
185
+ the engine is not involved. A cut between the two units of an emoji keeps
186
+ each half as its own three-byte sequence (the length of a half is one unit),
187
+ the form `str.split` gives its parts. Such a half never occurs inside a text
188
+ that holds the whole character, so three things differ from TradingView:
189
+ joining the two halves again, with `+` or `array.join`, does not give back
190
+ the original four bytes, so the joined text does not equal the original text;
191
+ a search for a half in the text it was cut from finds nothing (`str.pos`
192
+ returns -1, where the one byte the old cut gave was found at the same
193
+ position, and `str.contains` returns false); and a half is not equal to, or
194
+ at the start or end of, a part of that text that holds the whole character.
195
+ A begin position that lies inside the bytes of a text but past its units
196
+ (5 on "a", an emoji, "b") now stops the run; before, it returned the bytes
197
+ after that position.
198
+
199
+ ## 1.11.0 — 2026-11-09
200
+
25
201
  - `str.format_time` now uses TradingView's documented defaults when arguments
26
202
  are omitted: `"yyyy-MM-dd'T'HH:mm:ssZ"` for the format and the exchange time
27
203
  zone (`syminfo.timezone`) for the timezone. Pass `"yyyy-MM-dd"` and `"UTC"`
@@ -31,7 +207,6 @@ supported as exact pairs; on the 0.x line they are independent. See the
31
207
  explaining that v6 removed the argument and recommending an `if` statement
32
208
  around the call. Other unknown keywords keep `PF-E2027`.
33
209
  - Pine identifiers spelled like generated state members or helpers use the C++ name allocator, including history-bearing locals in requested helpers.
34
- - A local declared in a function or method and spelled like a built-in variable now keeps its own type, history storage and reads. Exceptions: a string local spelled like a price field (`open`, `high`, `low`, `close`, `hl2`, `hlc3`, `hlcc4`, `ohlc4`, `volume`) that is read with history in a function requested through `request.security` is still refused, as before; a string local that is read with history and used in a concatenation still does not compile, for any name; the support check still warns that `bar_index`, `last_bar_index` and `timenow` diverge from TradingView at every read of a local with that name; a script that declares the same built-in name in several callable shapes is accepted where an ordinary name is refused by the shared-Series check; and the confirmed-bar request receipt of a request inside the declaring function names the local by its internal storage spelling.
35
210
  - History retention can be selected with keyword-only `history_capacity`
36
211
  in `transpile()`, `transpile_full()`, `transpile_with_request_inventory()`
37
212
  and `gate/glue.py::transpile_json()`. The JavaScript worker template does
@@ -191,6 +366,17 @@ supported as exact pairs; on the 0.x line they are independent. See the
191
366
  seeds. Migration: none; undeclared runs are unchanged. The diagnostic stays
192
367
  an unconditional note at each `ta.ema` call; this text change leaves generated
193
368
  C++ unchanged.
369
+ - Missing integer values remain `na` in float writes, numeric selections,
370
+ float arguments and arithmetic. Explicit float declarations keep fractional
371
+ values after integer initialization. Regenerate C++ and relink strategies.
372
+
373
+ ## 1.10.0 — 2026-11-03
374
+
375
+ - Since 1.10.0, identifiers and import paths in Pine v6 scripts must be ASCII:
376
+ a non-ASCII character in a name is refused at that character (`no viable
377
+ alternative at character ...`); 1.9.1 encoded such names. Strings and
378
+ comments keep non-ASCII text, spelled as octal escapes in the generated C++
379
+ (#290).
194
380
  - An affine chart loop proved endless is stopped with the loop-time error when
195
381
  its result reaches an effect. Omission is limited to an unused loop statement
196
382
  with no calls, whose writes have no readers except self-updates, a break
@@ -199,10 +385,6 @@ supported as exact pairs; on the 0.x line they are independent. See the
199
385
  may drop them. Endless loops in functions, methods and `request.security`
200
386
  still never end here while TradingView stops them; data-dependent endless
201
387
  loops still hang.
202
- - Missing integer values remain `na` in float writes, numeric selections,
203
- float arguments and arithmetic. Explicit float declarations keep fractional
204
- values after integer initialization. Regenerate C++ and relink strategies.
205
-
206
388
  - Pine v6 calls refuse a positional argument after a named argument with
207
389
  `PF-E2074` at that positional expression. The check also covers strategy
208
390
  declarations, unused functions and v6 library bodies before lowering.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pineforge-codegen
3
- Version: 1.11.0
3
+ Version: 1.13.0
4
4
  Summary: PineScript v6 to C++ transpiler that targets the pineforge-engine runtime.
5
5
  Project-URL: Homepage, https://github.com/pineforge-4pass/pineforge-codegen-oss
6
6
  Project-URL: Issues, https://github.com/pineforge-4pass/pineforge-codegen-oss/issues
@@ -0,0 +1 @@
1
+ 1.13.0
@@ -74,6 +74,12 @@ publication failure also fails the job.
74
74
  | Native tests absent from the matrix | GKE PR / engine-main calls shared changes/native jobs; consumed by the same `gate` writer |
75
75
 
76
76
  The shared pytest matrix runs the same command as both former PR matrices.
77
+ Each Python version runs the suite as four jobs, one per part. Each job sets
78
+ `PF_TEST_SHARD` to its part, for example `2/4`, and `tests/conftest.py` keeps
79
+ the tests whose id hashes to that part, so the four jobs of a Python version
80
+ together run every test exactly once. The pytest job of the push and dispatch
81
+ workflow, `test.yml`, is cut the same way, and a test holds the matrix,
82
+ environment and commands of the two jobs equal.
77
83
  The differential leg retains Python 3.14, Node 22, the Pyodide selftest,
78
84
  dependency audit and full gate. Package metadata and entity checks run on every
79
85
  admitted diff, as does the workflow/App-environment guard.
@@ -70,7 +70,7 @@ tables (`HARD_REJECT_FUNC`, `HARD_REJECT_NAMESPACE`, `NOT_YET_FUNC`,
70
70
  | `visit_expr.py:443` | `session.<unknown>` → `"false"` | Known members being enumerated does not justify a value for an unknown member. The catch-all is a placeholder defect. |
71
71
  | `visit_expr.py:448` | `syminfo.<unknown>` → `"0"` | The historical whitelist blocked unknown members upstream; the emitter placeholder is still a defect. |
72
72
  | `visit_expr.py:459` | `color.<unknown>` → `"0"` | The historical whitelist covered known constants; an unknown-member placeholder is still a defect. |
73
- | `visit_expr.py:461` | `SKIP_NAMESPACES` (table/label/line/box/polyline/chart/linefill/display/size/position) → `"0"` | The audit treated these as visual omissions. Substituting zero for a missing value lowering is a defect; each supported member needs its semantics. |
73
+ | `visit_expr.py:461` (historical audit) | Legacy visual namespace fallbacks → `"0"` | Inventoried size, position, line/label style and shape constants now use typed string values from `builtin_constants.py` before these fallbacks. Remaining missing value lowerings are defects; rendering omissions do not justify substituting zero for a value. |
74
74
  | `visit_expr.py:484-507` | `strategy.oca.<unknown>`, `strategy.direction.<unknown>`, `strategy.commission.<unknown>`, `strategy.closedtrades.<unknown>`, `strategy.opentrades.<unknown>` catch-alls | Known enum values do not define unknown members. The catch-all defaults are placeholder defects. |
75
75
  | `visit_call.py:357` | `map.<unknown>(...)` → `"0"` | The historical whitelist rejected unknown functions upstream; the emitter placeholder is still a defect. |
76
76
  | `visit_call.py:404` | `array.<unknown>(...)` → `"0"` | The historical whitelist rejected unknown functions upstream; the emitter placeholder is still a defect. |
@@ -52,6 +52,9 @@ pineforge_codegen/
52
52
  │ (after generation; the C++ unchanged).
53
53
  ├── session_reads.py The session.<flag>[k] reads the generated
54
54
  │ C++ holds (analyzer and codegen share it).
55
+ ├── builtin_constants.py Typed scalar constant values shared by
56
+ │ analysis, emission and input proofs;
57
+ │ nominal builtin enums retain TypeSpec identity.
55
58
  ├── signatures.py Pine v6 builtin signature registry
56
59
  │ (TA / math / str / strategy / input /
57
60
  │ map / built-ins) — single source of
@@ -122,6 +125,9 @@ pineforge_codegen/
122
125
  │ enum is too coarse for.
123
126
  ├── tv_number_format.py TU-local numeric formatter emitted for
124
127
  │ str.tostring / str.format / log.*.
128
+ ├── tv_string_units.py TU-local UTF-16 unit counting and cutting
129
+ │ emitted for str.length / str.pos /
130
+ │ str.substring.
125
131
  ├── session_market.py session.ismarket of a chart bar in a run
126
132
  │ without a timeframe: the engine's session
127
133
  │ calendar asked at the bar's open time,
@@ -283,6 +283,9 @@ you delete or weaken the special case, the test will tell you.
283
283
  (`_collect_known_var`), where the reset read the alias's own member
284
284
  before the body set it, an EMA of length 0 for the whole run
285
285
  (`tests/test_e2e_alias_ta_length.py`, tapes `fixtures/alias_len_tv`).
286
+ Where a runtime constructor argument was narrowed to an integer, a float
287
+ signature slot instead retains its fraction, including VWAP band
288
+ multipliers; integer slots keep their narrowing and preserve `na`.
286
289
  14. **String escapes are the Pine manual's.** The lexer (`_read_quoted`)
287
290
  reads `\n` / `\t` as U+000A / U+0009 and `\\`, `\"`, `\'` as the
288
291
  character; any other `\X` reads as `X` ("the character's meaning does
@@ -362,7 +365,7 @@ you delete or weaken the special case, the test will tell you.
362
365
  `tests/test_e2e_cgint7_compositions.py`).
363
366
  16. **Every call argument is evaluated once.** Pine evaluates each argument
364
367
  of a call exactly once per execution; only `and` / `or` and the `?:` arms
365
- are lazy (a lab tv counting-probe tape, `fixtures/w2_trio_tv/eval_counts`,
368
+ are lazy (a TradingView counting-probe tape, `fixtures/w2_trio_tv/eval_counts`,
366
369
  shows every builtin slot below once per bar). A lowering template that
367
370
  reads an argument twice, or once per loop iteration, re-runs its C++, so a
368
371
  stateful call in it (a `ta.*` compute(), a user function with state) runs
@@ -442,7 +445,7 @@ you delete or weaken the special case, the test will tell you.
442
445
  handle shapes.
443
446
  18. **A script variable read through history in a function body reads its
444
447
  call site's history.** TradingView builds the history of a series used
445
- in a function through each call of it (`lab tv`, BINANCE:ETHUSDT.P 15,
448
+ in a function through each call of it (BINANCE:ETHUSDT.P 15,
446
449
  `tests/fixtures/function_global_history`): in a plain UDF, `x[k]` on a
447
450
  script variable (`var` or not) or on `bar_index` is `x` as that call site
448
451
  saw it at its latest call at or before `k` bars ago -- one slot per chart
@@ -1,5 +1,29 @@
1
1
  ## Support contracts
2
2
 
3
+ Persistent typed declarations parse their storage prefix separately from their
4
+ qualifier: `var const float`, `varip const int`, and the corresponding `simple`
5
+ and `series` forms retain both annotations and their existing initialization.
6
+
7
+ `request.security_lower_tf` tuple payloads, written inline or returned by a
8
+ helper, produce one array per element. Each intrabar evaluates the tuple once
9
+ before distributing values to the independently typed arrays; clearing the
10
+ request clears every array together. Tuple-bound arrays retain collection
11
+ metadata in global and callable scopes.
12
+
13
+ A global tuple declaration read by `request.security` is sampled once in the
14
+ requested evaluator, in declaration order. Scalar and history reads share that
15
+ sample, including stateful helper results. Member history commits on completed
16
+ requested bars even when a lazy payload does not read the member on that bar.
17
+ Helper parameter bindings remain active through `na`/`nz` builtin emission in
18
+ both evaluator modes. These rules supersede the older tuple refusal limitations
19
+ described in the historical helper row below.
20
+
21
+ Complete mixed tab/space nested block prefixes use four columns per tab plus
22
+ the spaces. Previously accepted incomplete mixed prefixes, skipped first-body
23
+ widths and pending logical-line continuations retain their earlier handling
24
+ pending additional TradingView observations; they are not newly refused as part
25
+ of the nested-block correction.
26
+
3
27
  Builtin `array.slice` on a resolved typed array in the script, a function or
4
28
  method parameter, or a callable-local array opens the view gate and lowers the
5
29
  script's array storage to typed handles:
@@ -20,6 +44,12 @@ lowering. Structural mutation, collection reassignment/escape, history and
20
44
  pair-binder iteration retain PF-E5086 pending TV evidence/provenance support;
21
45
  declaration tails yielding collections as callable/selection values are refused.
22
46
  `polyline.all` retains PF-E5085 until the engine has a Polyline handle/arena.
47
+ Polyline locals, array elements and UDT fields retain opaque typed handles;
48
+ default construction and bare `na` use a missing handle, and copies retain
49
+ its identity. `polyline.new` and functional or method-form `delete` keep the
50
+ existing visual-only rendering contract, while evaluating their arguments
51
+ once in parameter order. Opaque ID allocation joins script reset and rollback
52
+ state. This does not supply the live arena required by `polyline.all`.
23
53
  `var`/`varip` aliases retain PF-E5086 until a TradingView capture establishes
24
54
  their lifetime semantics. Whether a later creation in the same bar is visible
25
55
  through the alias is not yet measured against TradingView.
@@ -193,7 +223,7 @@ persistence against paired script controls.
193
223
 
194
224
  Numeric `matrix.sum(id1, id2)` returns a detached matrix for either a matrix or numeric scalar RHS; its existing one-argument aggregate lowering is unchanged. Scalar `matrix.diff`/`matrix.mult` also return detached matrices. Typed matrix/vector multiplication and a variable initialized from namespace `array.concat` are refused with the existing unsupported-function diagnostic. Default/index-only matrix row/column insertion fills with element na; omitted submatrix bounds, sort column and array-fill end use the collection dimensions. `tests/test_matrix_arithmetic_overloads.py` compiles and runs these overloads against the paired runtime.
195
225
 
196
- Keyword arguments of the matrix methods and of the checked array methods (`get`, `set`, `insert`, `remove`, `fill`, `slice`, `percentrank`, `first`, `last`, `pop`, `shift`, `sort`, `indexof`, `unshift`) bind to their own parameter slot (`CallVisitor._collection_arg_nodes`; the slots are `MATRIX_METHOD_KWARGS` and `CHECKED_ARRAY_METHOD_KWARGS`, and `row_index` / `col_index` of `add_row` / `add_col` keep binding to `row` / `column`), never shifted left over a gap: a gap before a later argument takes the omitted optional parameter's default in place (`matrix.sort(m, order = order.descending)` sorts column 0 descending, `m.submatrix(to_column = 1)` keeps every row, `a.fill(7.0, index_to = 1)` fills from 0). A keyword that names no parameter, a parameter given twice (by position and by keyword) and a gap before a required parameter are refused with the diagnostics the namespace already reports for a call that does not bind (`matrix.<method>: wrong number of arguments`; for an array method its `unknown keyword argument`, `passed both positionally and by keyword` and `missing required argument`, the typed-method templates). A call without keywords, and an array method outside the checked table, keep their arguments as written. `matrix.fill` binds its range keywords (`from_row`, `to_row`, `from_column`, `to_column`) as it binds a positional range, which the lowering does not apply: both fill the whole matrix, as before (an approximation TradingView does not make, unverified (hold)). `tests/test_arrseg_review_fixes.py` pins each keyword form against its positional twin and runs the defaulted ones. A defaulted `submatrix` evaluates its receiver once. An index-only `add_row` / `add_col` takes any numeric index (an input, a function's result, `math.min(...)`); an argument whose type the analysis cannot resolve is told from an array by its C++ type. A bound result of `array.concat` -- `c = array.concat(a, b)`, `c = a.concat(b)` on a variable declared an array and bound once, and the `:=` reassignments of both -- keeps the unsupported-function refusal; the statement form, `matrix.concat` and a user method named `concat` are unchanged. A matrix bound to a missing history (`b = m[20]`, then `b.get(0, 0)`) raises the recorded na-matrix text (RE10053), as the history itself does; one passed on to a function still raises the engine's text. Follow-ups, unverified (hold): matrix diff/mult dimension checks, a `for ... in` over a bound na array ID, keywords on an array method outside the checked table, on `matrix.new` and on a UDT field's matrix, and the `matrix.fill` range.
226
+ Keyword arguments of the matrix methods and of the checked array methods (`get`, `set`, `insert`, `remove`, `fill`, `slice`, `percentrank`, `first`, `last`, `pop`, `shift`, `sort`, `sort_indices`, `indexof`, `unshift`) bind to their own parameter slot (`CallVisitor._collection_arg_nodes`; the slots are `MATRIX_METHOD_KWARGS` and `CHECKED_ARRAY_METHOD_KWARGS`, and `row_index` / `col_index` of `add_row` / `add_col` keep binding to `row` / `column`), never shifted left over a gap: a gap before a later argument takes the omitted optional parameter's default in place (`matrix.sort(m, order = order.descending)` sorts column 0 descending, `m.submatrix(to_column = 1)` keeps every row, `a.fill(7.0, index_to = 1)` fills from 0). A keyword that names no parameter, a parameter given twice (by position and by keyword) and a gap before a required parameter are refused with the diagnostics the namespace already reports for a call that does not bind (`matrix.<method>: wrong number of arguments`; for an array method its `unknown keyword argument`, `passed both positionally and by keyword` and `missing required argument`, the typed-method templates). A call without keywords, and an array method outside the checked table, keep their arguments as written. `matrix.fill` binds its range keywords (`from_row`, `to_row`, `from_column`, `to_column`) as it binds a positional range, which the lowering does not apply: both fill the whole matrix, as before (an approximation TradingView does not make, unverified (hold)). `tests/test_arrseg_review_fixes.py` pins each keyword form against its positional twin and runs the defaulted ones. A defaulted `submatrix` evaluates its receiver once. An index-only `add_row` / `add_col` takes any numeric index (an input, a function's result, `math.min(...)`); an argument whose type the analysis cannot resolve is told from an array by its C++ type. A bound result of `array.concat` -- `c = array.concat(a, b)`, `c = a.concat(b)` on a variable declared an array and bound once, and the `:=` reassignments of both -- keeps the unsupported-function refusal; the statement form, `matrix.concat` and a user method named `concat` are unchanged. A matrix bound to a missing history (`b = m[20]`, then `b.get(0, 0)`) raises the recorded na-matrix text (RE10053), as the history itself does; one passed on to a function still raises the engine's text. Follow-ups, unverified (hold): matrix diff/mult dimension checks, a `for ... in` over a bound na array ID, keywords on an array method outside the checked table, on `matrix.new` and on a UDT field's matrix, and the `matrix.fill` range.
197
227
 
198
228
  `pineforge_codegen.support_checker` is the gate. Its job is to fail
199
229
  loudly **before** codegen so users never get a silently miscompiled
@@ -213,7 +243,14 @@ Checked settings string defaults and options use only known C++ string literals
213
243
  from the existing builtin lowering, never inert visual integer codes. Only the
214
244
  `currency.*` and `format.*` members inventoried in `NAME_ECHO_STRING_MEMBERS`
215
245
  may publish their own names, matching the body's existing lowering; unlisted
216
- members remain unsupported even when the body echoes their names. An unknown
246
+ members remain unsupported even when the body echoes their names. A default or
247
+ option held by a global variable, declared with or without `var`, is published
248
+ as its string when that variable is declared once, before the input, with a
249
+ string literal (or a constant expression of literals) and is never reassigned;
250
+ this applies to `input.string`, `input.timeframe`, `input.symbol`,
251
+ `input.session` and `input.text_area`. A default held by a variable that cannot
252
+ be proven this way is refused with PF-E5096 instead of becoming an empty
253
+ default; an option that cannot be proven keeps the rule below. An unknown
217
254
  string default or option marks the
218
255
  input `supported=false` and publishes no choices; its unavailable default is
219
256
  empty. Transpile-time input manifests reuse that descriptor's `supported`
@@ -264,6 +301,17 @@ This exception covers only constructs PineForge refuses today. A form that compi
264
301
  The emission invariant (`AGENTS.md#emission-invariant`) states this rule for every emission path. The notes in this file describe existing behavior: a documented approximation or unsupported fallback is an implementation gap, not an exception to the invariant.
265
302
 
266
303
  Input defaults use the input family's Pine type and qualifier contract.
304
+ Inventoried `size.*`, `position.*`, `line.style_*`, `label.style_*` and
305
+ `shape.*` members have string values independently of a visual call's
306
+ rendering support. `builtin_constants.py` supplies their value and semantic
307
+ type to analysis, emission and string-input proofs. Line styles also supply
308
+ box border styles. Assignments, selections and callable variants preserve
309
+ those types. `order.ascending` and `order.descending` instead retain nominal
310
+ `sort_order` TypeSpecs; their runtime storage does not permit a Pine string
311
+ conversion. Typed slots and operator contracts check that identity.
312
+ `tests/test_builtin_style_values.py` covers the value paths, named bindings
313
+ and nominal restrictions, including order arguments of collection sorting.
314
+
267
315
  An explicit `const color` carrier with a proven initializer supplies its
268
316
  packed value to the getter and settings descriptor before `on_bar`; the
269
317
  manifest reads that descriptor. `codegen/constant_values.py` resolves lexical
@@ -321,7 +369,7 @@ The taxonomy:
321
369
  | Color na conversions | Packed colors use `int64_t` storage, including typed scalar, array and matrix paths, so their `na<int64_t>()` sentinel survives. `array.from` of colors is a `std::vector<int64_t>`: a color literal, a `color.*` constant, a `color.new` / `rgb` / `from_gradient` call, a conditional selecting one or a script variable bound to one types the element on both sides (`_is_color_value`, the analyzer's `_is_color_constructor`); it was read as a float, and `var array<color> A = array.from(...)` did not compile (`tests/test_e2e_color_arrays.py`, tape `fixtures/silent2_tv/cgs2_color_arrays`). `color.new` preserves an `na` base; `na` transparency becomes 100; an `na` `color.rgb` channel becomes zero. The covered TradingView color probes are pinned by `tests/test_na_truthiness.py`. A finite transparency reaches the engine's `new_color` as a double, whose alpha byte is the nearest to 255 * (100 - t) / 100, as TradingView's for an input or a series transparency and `color.rgb`'s: `color.new(c, t)` at t = 10.5 reads back 11 (a truncating cast read 10; an integer literal keeps its `(int)` spelling). TradingView truncates a constant `color.new` transparency (`color.new(color.red, 10.5)` and `10.6` read 10, `99.5` reads 99), which PineForge still reads through the byte (pinned: `tests/test_e2e_cgint6_compositions.py`, tape `fixtures/cgint6_tv/cgint6_const_transp`). `tests/test_e2e_color_tapes.py` replays the engine's `w11-color-v6-eth15` tape (`fixtures/color_tv`). `color.new(color, transp)`, `color.rgb(red, green, blue, transp)` and `color.r` / `g` / `b` / `t(color)` bind a keyword argument to its parameter's slot, in parameter order (`_color_arg_nodes`; a keyword transparency is converted as a positional one): a keyword was dropped, so `color.new(c, transp = 40)` lowered to the color 0 (`tests/test_e2e_color_keyword_arguments.py`, tape `fixtures/silent2_tv/cgs2_color_keywords`). |
322
370
  | Epoch ints | A Pine `int` slot an epoch reaches is `int64_t`: a name whose declaration or any reassignment gives it a wide value (an epoch builtin, a wide name or parameter, or an expression `_expr_returns_wide_int` traces to one), and a declared-`int` or untyped parameter a written call feeds one (`types._wide_int_provenance`, a fixed point keyed by spelling). The width used to stop at the first copy: `int sel = switch k => E2` over `const int E2 = timestamp(...)`, `alias = firstT` over `firstT := time`, and `f(int t)` called with `time` held 32 bits (1743468300000 read -288422176), and `int(x)` of an epoch casts to `int64_t` (`int(time)` was a 32-bit cast). A function's or method's local declared `float` keeps a float series when an epoch reaches it (`float x = time`: `_callable_series_local_symbol` reads the function's scope, `method_<Type>_<name>` for a method, which the global lookup missed): its `Series<int64_t>` read the integer sentinel for a missing `x[1]`, so `x - x[1]` was a garbage number on the first bar instead of na (`tests/test_e2e_float_time_local.py`, tapes `fixtures/silent2_tv/cgs2_float_time_local` and `cgs2_float_time_method`). `tests/test_e2e_krunerr_int64_provenance.py` replays TradingView's tape (`fixtures/krunerr_tv`). A method call's arguments do not widen its parameters. Integer arithmetic over literals and the constants emitted as literals keeps 64 bits too: `400 * MS` over `const int MS = 7200000` is 2880000000 (it was the C++ `int` product, -1414967296), folded where the tree is literal after the names are inlined (`_pure_int_literal_value`, `_inlined_int_constant`) and where the emitted C++ is (`_fold_int32_overflow_cpp`: a `request.security` payload expands a global into its declaration), and the slot a top-level declaration of an int constant past int32 initializes is `int64_t`, reassigned or not (`g = 3000000000`, `var int e = 300 * MS`: `_literal_wide_global`); a literal's width (`g = 3000000000`) reaches a declaration reading it while it is never reassigned (`h = g`) but does not travel by spelling into a reassignment (`k := g`), parameters, arrays, `request.security` helper state or a callable's local of the same name, which keep the types they compiled with, while constant arithmetic (`300 * MS`) is a 64-bit product too, whose width travels as the next sentences say. `tests/test_e2e_int64_constants.py` replays TradingView's tape (`fixtures/silent_tv`). An integer `+ - *` those folds leave, whose operands are both 32-bit C++ ints, is computed in 64 bits at run time when its magnitude can leave int32 (`_int_arith_leaves_int32`: literals and inlined constants exactly, an `input.int` by its declared range, else its default and 2**24, `bar_index`, a counted loop's binder, a `for ... in` binder whose spec is `int` (an int element, map value or index; a float element is a double: `v * 1000` over one was truncated) and any other runtime integer name 2**24 (a call's result does not widen); a callable's name resolves in its own callable, a declared `int` local included, whichever callable is being emitted; a reassigned top-level constant past int32, whose slot is `int64_t`, is no 32-bit operand, and an input's named bound reads the top-level constant), and its value is an epoch-like wide value for the slots above: `days * 86400000` over `days = input.int(30)` and `bar_index * 7200000` overflowed. An operand that can be na (a parameter, a local, a script variable) makes the value na: a double (`_wide_int_arith_cpp`, exact to 2**53; the widening cast read `na<int>()` as -2147483648) that every integer store narrows na-preserving, a slot, a parameter, an array element, a map or matrix value. In a `request.security` payload a side the builder re-evaluates as a double computes in double and a name a helper binds keeps its spelling; the rest widens as on the chart, and the payload's copy of a script variable only such arithmetic makes wide is `int64_t` too (`_security_copy_is_arithmetic_wide`, stored na-preserving, a compound `%=` through `std::fmod`); an epoch's or an int-literal product's keeps its `int` copy, as it always did. A tuple element and a function's or method's result holding a constant past int32 (`_holds_wide_int_constant`), and a read of a UDT `int` field (`int64_t` storage) some write fills with one (`_wide_udt_int_fields`), are `int64_t` too. A `map<..., int>` value, `matrix<int>` element or element of an int array only such a value reaches (only an epoch widens an array, `_wide_int_array_names`: a declared `array<int>` parameter, result or field does not bind a `std::vector<int64_t>`) keeps its C++ `int` (its type also types the handle's parameters and its `values()` / `row()` arrays), narrows the value na-preserving and warns where it stores one (`tests/test_e2e_int64_products.py`, tapes `fixtures/silent2_tv/cgs2_int64_products`, `cgs2_int64_followup` and `cgs2_int64_followup2`). |
323
371
  | Array and matrix history | `a[k]` of an array or a matrix variable is TradingView's read-only copy of the collection as the variable left it at the end of its scope's execution k executions back: the bar k bars back for the top level, its block's previous run for a block's local (`tests/fixtures/array_history_tv`). A `var` array's history is the copy, one element shorter than the array it grows (`ahist_ref`), and a `var` matrix's holds the previous bar's value (`ahist_mtx`). The variable keeps its own `std::vector` or matrix member, so every other operation keeps its C++; `_pf_collection_hist_<name>` (`_PFCollectionHistory`, `pineforge_codegen/collection_history.py`) keeps the copies of one declaration: each execution of the declaration (each bar, for a top-level `var`) opens a slot and the bar's end closes it with a copy. Sibling blocks declaring the same name share its member, so each declaration gets a history of its own (`_pf_collection_hist_1_<name>`, ..., which no Pine name spells) and first closes the others' with the array their block left (`ahist_sibling`: one shared history read the other block's array, 336 of 336 exits wrong). `CollectionHistoryChecker.decide` gives every read one outcome. Supported, for a variable of the top level or one of its blocks: a built-in reads it (`(a[1]).size()`, `array.get(a[1], 0)`, `(m[1]).get(0, 0)`, `matrix.det(m[1])`; a matrix function's new matrix has the variable's type, `matrix.copy(mi[1])` of a `matrix<int>` too); a built-in that changes it stops the run with TradingView's RE10051 text (`(a[1]).push(x)`; a zero offset is the variable itself, which changes); `na()` asks whether a copy exists; a `for...in` loop over it iterates the variable's current array, as TradingView's does (`ahist_loop`: `for v in b[1]` sums the current array); a variable bound to it holds a nullable reference to a copy (`_PFArrayHistoryValue` for arrays, the native na matrix for matrices), including a binding read only through `na()` or both through `na()` and array methods -- unless the value reaches a user function's or method's parameter, directly (`f(a[1])`, `(a[1]).m()`) or through a bound name (`pb = a[1]`, `f(pb)`, `pb.m()`): that stays the copy it was before the nullable value (`.value(k)`, an empty array before the variable has a history, where TradingView's is na: the callee's parameter is a `std::vector&` that holds no na array), and a callee that also reads it through `na()` keeps the earlier refusal (`NameUses.crosses_parameter`; `tests/test_arrseg_review_fixes.py`). An unavailable literal or dynamic offset yields an na ID, distinct from an empty collection. Aliases and array-valued ternary selections preserve that ID; an array method materializing it stops with the existing na-array error. Array-ID unwrapping retains temporary values for range loops. A method on a na history stops the run (RE10052, RE10053). Refused by name, what TradingView refuses: a method straight after the history (`a[1].size()`: CE10011), an object's array, matrix or map field's history (`h.xs[1]`, `(h.xs)[1]`: CE10290, in the analyzer), an array where a number, a condition, a string or an element is expected (CE10123: an operator, `nz`, `math.*`, a value slot of an array function such as `c.push(a[1])` or `array.new<float>(2, a[1])`, `log.info`'s message, `label.new`'s text, `str.tostring` of colors; CE10173: a scalar variable or field; CE10101: an if or while condition; CE10122: `array.from`, `str.format` of colors; CE10009: a bare statement of the top level). Every other read keeps the lowering it had where that compiled -- an element of the current array (`na()` and `str.tostring()` in a function, a request payload, a loop, a block's `var`; a selection's history), a parameter's current array (a namespace call, a for...in loop, a typed copy), each with a warning, and anything in a function no call names, which the codegen does not emit (it emits every method and every function a call names, an uncalled function's call included: a read there is decided as any, and one an uncalled function hands to such a function's untyped parameter by how that body uses it) -- and is refused where it did not, as probes of every use and every array function in every scope and for every element type against the previous build showed (`_ELEMENT_LOWERING_FAILS` and its siblings): a collection use of a number element (a method, any `array.*` read but `array.copy` into a namespace call or a loop's local, a typed parameter or binding, a loop over a number) and the string ones `std::string` lacks, `na()` or `str.tostring()` of a parameter's array and its array-returning reads, a change through a variable or a slice bound to the history (TradingView stops there, RE10051; PineForge would change a copy), a matrix's history outside the scopes kept, a call's result's history. Whether an earlier lowering compiled often turns on the consumer of an array function's value, which the tags carry (`_array_result_consumer`: a method on the new array, a function returning it, rendering it, a member holding it; `_value_consumer`: a string value returned or bound), and an overloaded method given the history keeps the earlier lowering. `xs[k] := v`, which TradingView refuses (CE10009, CE10013), keeps its element assignment with checked bounds. Other legacy current-element reads keep their warning and return element na outside the array instead of indexing unchecked. `tests/test_collection_history_missing.py` compiles and runs missing-history witnesses for arrays, matrices, UDTs and drawings, na methods, aliases, dynamic offsets and legacy paths. An object's array or matrix field read through the object's history (`(h[1]).xs.size()`) is the field as it is now (`ahist_field`), as it compiled before. Map history stays refused. Two gaps keep the C++ the previous build emitted, which does not compile: an element function's value of a string array's history the earlier lowering reads (`f() => str.length(array.first(s[1]))`: a character of the current array's string, held as a number, which most string consumers do not take; the probes measured a value bound or returned), and the history of a variable or a call the analyzer does not type as an array or a matrix (a method's or `matrix.row`'s new array, a selection of arrays, a tuple's element, an array of drawings), which the checker never sees. `tests/test_array_history.py` compiles every shape and pins the refusals and the earlier lowerings; `tests/test_e2e_array_history.py` replays six tapes and the runtime stops. |
324
- | syminfo na-gap warning | `SUPPORTED_SYMINFO` = every `SYMINFO_MEMBER_MAP` key, but members whose emission is `na<T>()` or a `get_syminfo_metadata(...)` lookup (root/pricescale/minmove/mincontract/current_contract/expiration_date/isin/sector/industry + fundamentals/recommendations/target_price_*) form `_SYMINFO_SILENT_GAP_FIELDS` (derived from the emission table, so new na-accept fields can't drift out): every read WARNS that the value is na until a data feed injects it. `syminfo.timezone` spells an empty or `UTC` exchange zone `Etc/UTC`, TradingView's name for BINANCE's (`syminfo.timezone == "Etc/UTC"` holds there, `== "UTC"` does not); the engine calls that take the symbol's zone keep the engine's name (`tests/test_e2e_syminfo_timezone_spelling.py`, `fixtures/tail_e_tv`). `syminfo.mincontract` (`_SYMINFO_RUN_FACT_FIELDS`) reads the symbol fact the run declares as syminfo metadata `"mincontract"` (`runtime_overrides.syminfo_metadata`, a lane fact beside `qty_step`) and warns that it is na without one; lab tv read-outs give TradingView's values (0.0001 ETHUSDT.P, 0.00001 BTCUSDT, 0.01 EURUSD/XAUUSD, 1 on the stock, index and futures lanes; `tests/test_e2e_syminfo_mincontract.py`). |
372
+ | syminfo na-gap warning | `SUPPORTED_SYMINFO` = every `SYMINFO_MEMBER_MAP` key, but members whose emission is `na<T>()` or a `get_syminfo_metadata(...)` lookup (root/pricescale/minmove/mincontract/current_contract/expiration_date/isin/sector/industry + fundamentals/recommendations/target_price_*) form `_SYMINFO_SILENT_GAP_FIELDS` (derived from the emission table, so new na-accept fields can't drift out): every read WARNS that the value is na until a data feed injects it. `syminfo.timezone` spells an empty or `UTC` exchange zone `Etc/UTC`, TradingView's name for BINANCE's (`syminfo.timezone == "Etc/UTC"` holds there, `== "UTC"` does not); the engine calls that take the symbol's zone keep the engine's name (`tests/test_e2e_syminfo_timezone_spelling.py`, `fixtures/tail_e_tv`). `syminfo.mincontract` (`_SYMINFO_RUN_FACT_FIELDS`) reads the symbol fact the run declares as syminfo metadata `"mincontract"` (`runtime_overrides.syminfo_metadata`, a per-run fact beside `qty_step`) and warns that it is na without one; fixture readouts give TradingView's values (0.0001 ETHUSDT.P, 0.00001 BTCUSDT, 0.01 EURUSD/XAUUSD, 1 for the stock, index and futures symbols; `tests/test_e2e_syminfo_mincontract.py`). |
325
373
  | Session flags | A chart bar's `session.ismarket` reads the kernel's in-session fact `session_ismarket_`, which reads the bar at its interval's first eligible instant: its open, or the reopen for a bar that opens in a break (TradingView's TSE:7203 and CBOT:ZC1! 60-minute bars that open at 12:00 and 08:00 are in market); a D/W/M bar is in market. TradingView flags a bar by its open time (on a US-listed stock's extended-hours 60-minute chart the 09:00 bar, which holds the 09:30 open, is pre-market and the 16:00 bar post-market), reads a day mask per session day, and flags OANDA:XAUUSD's daily bars, stamped at the 17:00 ET break, in market. A run with no timeframe (one bar, none given: `script_tf_` is empty) gets no session-day facts (`session.isfirstbar` / `islastbar` read false there, as the test pins); there the emitted `_PFSessionMarket` type and its per-strategy `_pf_session_market_` cache (`codegen/session_market.py`, outside the checkpointed script state) ask the engine's session calendar (`native_calendar::session_day_at`) about the bar's open time. Both replaced the time-of-day predicate, which missed every Sunday-evening open under a `:23456` mask and every `0000-2400` bar until the engine's time/color fix read a mask by each window's session day and `2400` as the day's end (the predicate now reads those tapes as TradingView does); the calendar at the bar's open, the chart's lowering before the session-window handling, puts the break-open bars of the intraday tapes out of market. A bar in market is in neither `session.ispremarket` nor `session.ispostmarket`; off it, the engine's windows decide (`session_in_premarket` / `session_in_postmarket`, src/session_time.cpp): from 04:00 to the session day's first open and from its last close to 20:00, over every window in either order; a bar between two windows is neither, and so is every bar of an overnight or 24-hour session (the session-window handling; the windows used to read the first window only, and also held in-market bars of overnight sessions). TradingView's two-window charts TSE:7203, HKEX:700 and CBOT:ZC1! hold no off-market bar and flag none pre- or post-market (`tests/test_e2e_session_windows.py`). A `request.security` payload's own session reads, a user function's it inlines included, keep the time-of-day predicates at the security bar's open time, a D/W/M bar's too, which TradingView reads as whole session days, and WARN. `session.isfirstbar` / `islastbar` read the host's `session_isfirstbar_` / `session_islastbar_`, the chart's session day, which the engine widens by the pre- and post-market bars an extended-hours chart holds (the extended-hours tape's 04:00 and 19:00 bars), and the `_regular` spellings its `session_isfirstbar_regular_` / `session_islastbar_regular_`, the regular day (10:00 and 15:00; they used to read the chart's pair). Under TSE:7203's published 15:30 end the regular day closes on the 15:15 bar, where TradingView's closes on its 15:30 bar (pinned). `tests/test_e2e_session_ismarket.py` replays TradingView tapes (public crypto tapes in `tests/fixtures/session_ismarket`; US-listed stock, US futures, forex and spot-metal tapes overlaid onto the paired engine's private `tests/codegen-fixtures/session_ismarket`) and `tests/test_e2e_session_windows.py` the three two-window charts at 15, 60 and 240 minutes, on their own bars and, for TSE:7203 and CBOT:ZC1!, aggregated from 15 minutes (the engine aggregates HKEX:700 on a 09:30-anchored grid, not TradingView's clock hours), each replay ending on the bar TradingView's chart holds next (a batch's final bar closes its session day); TradingView's HKEX:700 bars above 15 minutes, whose session day it gives two first bars (60) or makes every bar first and last (240), are pinned. |
326
374
  | Session flag history | `session.<flag>[k]` is the flag k bars ago at the top level of a script, in a block and on a lazy operand too, and k calls ago inside a function, each call site apart and whichever operand or block of the function holds the read, as a US-stock tape kept in a private repository shows; a read before the first bar is false. A top-level read indexes the flag's `_pf_session_hist_<flag>` Series, pushed at the top of every chart bar. A function that reads a flag at an offset is emitted once per call site (the analyzer's synthetic-history statefulness) and pushes the flag into its `_session_call_*` Series at entry, once per call. A `request.security` expression that reaches the read through its own operators keeps a bool `_sec<N>_expr_hist_*` Series on the requested clock (a function whose only read sits in its own request.security keeps no per-call Series), as does a builtin call's argument the payload builder lowers on the requested clock (`nz(session.ismarket[1] ? 1.0 : na)`: the `request.security` helpers row); one that reaches it through a variable, or through a call's argument where the evaluator keeps the chart's terms, and a read in a function or method such an expression evaluates (the analyzer follows its calls, the variables it reads and their statements), is refused at the read. The codegen also refuses a read it emits in a method (a call on a receiver the analyzer cannot type, such as `mk().m()` or a loop variable, is not told apart) or in a function a method, such an expression or a UDT field default reaches (`session_history_unsafe`; the analyzer follows a global's name as the evaluator does, whatever a function binds itself). Both follow the emitted C++, not the rendered reads (`_settle_session_reads`): a refused read renders as a stand-in name, refused only if the code outside comments and literals holds it, so a read the C++ never holds (in `plot`, `alert`, a drawing's style or xloc, `color.from_gradient`, any argument the codegen drops or renders and leaves out) refuses nothing: such callables get no clone, and `transpile()` first analyzes a script without the clones of functions that read a flag at an offset, then again with the functions whose reads that C++ holds cloned as well, until it asks for no more (a clone can make a caller's read reach the C++) (`pineforge_codegen/session_reads.py`, `_generate`), so the others keep the calls they compiled with and never cost a clone (a clone could also put a wrapper's int and float calls on one variant, and a function called along a deep call tree gets one per path); a top-level one may leave an unused Series. It used to index a C++ bool and fail the compile. `tests/test_e2e_session_history.py` replays the three tapes. |
327
375
  | Drawing lifetime | A deleted drawing reads like a na handle: every getter returns na, every setter does nothing and `na()` is true (a na handle's getter reads na too, instead of halting the run). A new line, box or label that makes its kind's live count reach `max_<kind>_count + 6` (default 50) deletes the oldest drawings of that kind no `var`/`varip` or history-read variable holds, until `max_<kind>_count` remain; a drawing held only by an array, an object field, a local or a plain non-var variable is collectable, and linefills are never collected. The engine's arena reads a deleted record's data and evicts at exactly the cap, so the generated arenas are unbounded and the TU carries the rule (`DRAWING_LIFETIME_CPP` and the `_pf_collect_<kind>s_` members, `codegen/drawing.py`). `tests/test_e2e_drawing_lifetime.py` replays 15 TradingView readout tapes (`tests/fixtures/drawing_lifetime`) value by value. |