pineforge-codegen 1.6.2rc1__tar.gz → 1.6.3__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 (75) hide show
  1. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/CONTRIBUTING.md +49 -1
  2. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/LEGAL.md +2 -2
  3. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/LICENSE +3 -3
  4. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/PKG-INFO +5 -5
  5. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/README.md +1 -1
  6. pineforge_codegen-1.6.3/VERSION +1 -0
  7. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/base.py +4 -0
  8. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/types.py +16 -5
  9. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/visit_call.py +106 -2
  10. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/visit_expr.py +34 -4
  11. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/visit_stmt.py +5 -0
  12. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/parser.py +29 -5
  13. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/pine_libraries.py +1 -1
  14. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/support_checker.py +21 -0
  15. pineforge_codegen-1.6.2rc1/VERSION +0 -1
  16. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/.gitignore +0 -0
  17. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/CHANGELOG.md +0 -0
  18. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/docs/PUBLIC_CONTRACT.md +0 -0
  19. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/docs/codegen-coverage-gaps.md +0 -0
  20. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/docs/pine-cap-activation.md +0 -0
  21. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/__init__.py +0 -0
  22. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/__init__.py +0 -0
  23. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/base.py +0 -0
  24. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/call_handlers.py +0 -0
  25. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/contracts.py +0 -0
  26. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/diagnostics.py +0 -0
  27. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/tables.py +0 -0
  28. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/types.py +0 -0
  29. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/ast_nodes.py +0 -0
  30. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/block_locals.py +0 -0
  31. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/builtin_keywords.py +0 -0
  32. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/__init__.py +0 -0
  33. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/capabilities.py +0 -0
  34. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/checked_settings.py +0 -0
  35. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/collection_history.py +0 -0
  36. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/constant_fold.py +0 -0
  37. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/drawing.py +0 -0
  38. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/emit_top.py +0 -0
  39. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/helpers.py +0 -0
  40. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/helpers_syminfo.py +0 -0
  41. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/host_members.py +0 -0
  42. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/input.py +0 -0
  43. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/order_shapes.py +0 -0
  44. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/run_stops.py +0 -0
  45. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/security.py +0 -0
  46. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/session_market.py +0 -0
  47. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/ta.py +0 -0
  48. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/tables.py +0 -0
  49. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/tv_number_format.py +0 -0
  50. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/collection_history.py +0 -0
  51. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/cpp_allowlist.py +0 -0
  52. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/diagnostic_codes.py +0 -0
  53. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/diagnostics_catalog.json +0 -0
  54. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/errors.py +0 -0
  55. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/external_requests.py +0 -0
  56. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/finite_ta_length.py +0 -0
  57. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/lexer.py +0 -0
  58. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/library_inline.py +0 -0
  59. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/library_modules.py +0 -0
  60. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/library_v5.py +0 -0
  61. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/limits.py +0 -0
  62. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/matrix_overloads.py +0 -0
  63. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/method_binding.py +0 -0
  64. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/pine_spelling.py +0 -0
  65. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/pragmas.py +0 -0
  66. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/request_discovery.py +0 -0
  67. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/request_feed_inventory.py +0 -0
  68. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/security_contexts.py +0 -0
  69. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/session_reads.py +0 -0
  70. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/signatures.py +0 -0
  71. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/symbols.py +0 -0
  72. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/timeframe_token_cli.py +0 -0
  73. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/tokens.py +0 -0
  74. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pineforge_codegen/tv_input_choices.py +0 -0
  75. {pineforge_codegen-1.6.2rc1 → pineforge_codegen-1.6.3}/pyproject.toml +0 -0
@@ -4,7 +4,7 @@ This is the source-available PineScript v6 to C++ translator. Read the
4
4
  [license and contribution terms](LEGAL.md) before sending a material change.
5
5
  Contributions use the Developer Certificate of Origin: add a `Signed-off-by`
6
6
  line with `git commit -s`. Material contributions also require a Contributor
7
- License Agreement so pineforge, LLC can include them in its commercial licenses;
7
+ License Agreement so PINEFORGE LLC can include them in its commercial licenses;
8
8
  contact luis@4pass.com.tw before opening a material pull request.
9
9
 
10
10
  ## Local setup
@@ -109,6 +109,54 @@ the Python `build` frontend, run `python -m build`, assemble the npm payload,
109
109
  then run `npm pack --dry-run` from `npm/`. These commands build local artifacts;
110
110
  publishing is a separate release operation.
111
111
 
112
+ ## npm publication (operators)
113
+
114
+ The release and npm publication workflows run on GitHub-hosted runners.
115
+ Run both workflows with `workflow_dispatch` on `main`.
116
+ `release.yml` publishes to PyPI, commits and pushes the release tag, then
117
+ creates the GitHub Release and notifies the release hub. After the tag exists
118
+ on main and the release job is green, the operator doing the cut, using a
119
+ GitHub account with write access, publishes npm with this separate dispatch:
120
+
121
+ ```sh
122
+ gh workflow run publish-pyodide.yml --repo pineforge-4pass/pineforge-codegen-oss --ref main -f tag=<tag> -f dry_run=false
123
+ ```
124
+
125
+ Use the existing release tag in place of `<tag>`. Set `dry_run=true` to
126
+ validate first. A tag push alone publishes nothing. A green `release.yml`
127
+ run does not mean npm published; watch the `publish-pyodide.yml` run.
128
+ Every npm run requires an existing release tag, including dry runs and
129
+ placeholder claims. Its first job, `tag-guard`, has only Contents read
130
+ permission and checks out main with credentials persistence disabled. It
131
+ checks the dispatch ref is `refs/heads/main`, validates the release pattern
132
+ (`vX.Y.Z` or `vX.Y.Z-{alpha,beta,rc}.N`) before using the input in git,
133
+ fetches tags and full main history, peels the tag to a 40-hex commit and
134
+ checks that commit is an ancestor of `refs/remotes/origin/main`.
135
+ A missing tag, a tag that cannot peel to a commit, an invalid name or a tag
136
+ outside main fails the run before either npm job can start. Publish checks
137
+ out the verified commit SHA with credentials persistence disabled, verifies
138
+ its `VERSION`, and runs the gate before publishing. The workflow run stays
139
+ at `refs/heads/main` while its checkout uses the pinned commit; moving the tag
140
+ after verification does not change what gets built.
141
+
142
+ For a manual npm dry run, dispatch `publish-pyodide.yml` on `main` with
143
+ `dry_run=true` and an existing release `tag` on main. For a real npm retry
144
+ after a successful tag push, dispatch on `main` with the existing release
145
+ `tag` and `dry_run=false`. A placeholder claim uses `claim_placeholder=true`
146
+ and the same required tag guard. The guard fails a dispatch at another ref;
147
+ both npm jobs also retain their main-ref job conditions and require the
148
+ guard to succeed.
149
+ The guard and job conditions live in the workflow file on `main`, but GitHub
150
+ executes the file from the dispatched ref, so they alone cannot stop a user
151
+ with write access who pushes and dispatches a modified workflow on another
152
+ branch. The server-side bound is the GitHub environment `npm-publish`: both npm
153
+ jobs (`publish` and `claim-npm`) run in it, and it carries a `main`-only
154
+ deployment-branch policy, so a run from any other ref is refused by GitHub. The
155
+ npm trusted publisher for the package is set by the repository owner to require
156
+ that environment (owner decision NPM-TP; that setting lives on npmjs.com and
157
+ cannot be read from this repository), so a publish from a workflow that does not
158
+ declare the environment fails at npm.
159
+
112
160
  ## Change and review notes
113
161
 
114
162
  - Add or update tests for behavior changes. Keep the engine corpus compiling;
@@ -19,7 +19,7 @@ The PineForge Source License 1.1 replaced 1.0, and 1.2 replaces 1.1, for the cod
19
19
 
20
20
  ## Copyright and licensor
21
21
 
22
- The licensor is **pineforge, LLC**, a Delaware limited liability company. It holds the copyright in `pineforge-codegen`; the founder's rights in the software are assigned to it. Commercial licenses are granted by pineforge, LLC.
22
+ The licensor is **PINEFORGE LLC**, a Delaware limited liability company. It holds the copyright in `pineforge-codegen`; the founder's rights in the software are assigned to it. Commercial licenses are granted by PINEFORGE LLC.
23
23
 
24
24
  ## What this repository is
25
25
 
@@ -35,7 +35,7 @@ The transpiler has **no runtime dependencies** (`transpile()` and `transpile_ful
35
35
 
36
36
  ## Contributions
37
37
 
38
- Contributions are accepted under a Developer Certificate of Origin (`Signed-off-by`). Because this project is **dual-licensed** (source-available + a sold commercial license), material contributions require a Contributor License Agreement granting pineforge, LLC the right to include the contribution in its commercial licenses; otherwise it cannot be accepted. See [CONTRIBUTING.md](CONTRIBUTING.md) (or contact luis@4pass.com.tw) before opening a material PR.
38
+ Contributions are accepted under a Developer Certificate of Origin (`Signed-off-by`). Because this project is **dual-licensed** (source-available + a sold commercial license), material contributions require a Contributor License Agreement granting PINEFORGE LLC the right to include the contribution in its commercial licenses; otherwise it cannot be accepted. See [CONTRIBUTING.md](CONTRIBUTING.md) (or contact luis@4pass.com.tw) before opening a material PR.
39
39
 
40
40
  ## No warranty
41
41
 
@@ -9,9 +9,9 @@ person's own account or capital. In the Commercial Use section, the
9
9
  definition of investment capital now covers the capital in such an
10
10
  account, real or simulated.
11
11
 
12
- Copyright 2025-2026 pineforge, LLC
12
+ Copyright 2025-2026 PINEFORGE LLC
13
13
 
14
- Required Notice: Copyright 2025-2026 pineforge, LLC (https://github.com/pineforge-4pass/pineforge-codegen-oss)
14
+ Required Notice: Copyright 2025-2026 PINEFORGE LLC (https://github.com/pineforge-4pass/pineforge-codegen-oss)
15
15
 
16
16
  The software is free of charge for the permitted purposes below, including
17
17
  Personal Trading. Commercial Use, defined below, needs a separate commercial
@@ -242,7 +242,7 @@ kind of legal claim.***
242
242
 
243
243
  ## Definitions
244
244
 
245
- The **licensor** is pineforge, LLC, and the **software** is the software the
245
+ The **licensor** is PINEFORGE LLC, and the **software** is the software the
246
246
  licensor makes available under these terms.
247
247
 
248
248
  **You** refers to the individual or entity agreeing to these terms.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pineforge-codegen
3
- Version: 1.6.2-rc.1
3
+ Version: 1.6.3
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
@@ -18,9 +18,9 @@ License: PineForge Source License 1.2
18
18
  definition of investment capital now covers the capital in such an
19
19
  account, real or simulated.
20
20
 
21
- Copyright 2025-2026 pineforge, LLC
21
+ Copyright 2025-2026 PINEFORGE LLC
22
22
 
23
- Required Notice: Copyright 2025-2026 pineforge, LLC (https://github.com/pineforge-4pass/pineforge-codegen-oss)
23
+ Required Notice: Copyright 2025-2026 PINEFORGE LLC (https://github.com/pineforge-4pass/pineforge-codegen-oss)
24
24
 
25
25
  The software is free of charge for the permitted purposes below, including
26
26
  Personal Trading. Commercial Use, defined below, needs a separate commercial
@@ -251,7 +251,7 @@ License: PineForge Source License 1.2
251
251
 
252
252
  ## Definitions
253
253
 
254
- The **licensor** is pineforge, LLC, and the **software** is the software the
254
+ The **licensor** is PINEFORGE LLC, and the **software** is the software the
255
255
  licensor makes available under these terms.
256
256
 
257
257
  **You** refers to the individual or entity agreeing to these terms.
@@ -931,7 +931,7 @@ use `python -m pytest --collect-only -q` for the current collection count.
931
931
  ## License
932
932
 
933
933
  Source-available under the [PineForge Source License 1.2](https://github.com/pineforge-4pass/pineforge-codegen-oss/blob/main/LICENSE);
934
- the `LICENSE` file is the controlling text. The licensor is pineforge, LLC.
934
+ the `LICENSE` file is the controlling text. The licensor is PINEFORGE LLC.
935
935
 
936
936
  - **Free for noncommercial use:** any noncommercial purpose, and use by a
937
937
  charitable organization, educational institution, public research
@@ -646,7 +646,7 @@ use `python -m pytest --collect-only -q` for the current collection count.
646
646
  ## License
647
647
 
648
648
  Source-available under the [PineForge Source License 1.2](https://github.com/pineforge-4pass/pineforge-codegen-oss/blob/main/LICENSE);
649
- the `LICENSE` file is the controlling text. The licensor is pineforge, LLC.
649
+ the `LICENSE` file is the controlling text. The licensor is PINEFORGE LLC.
650
650
 
651
651
  - **Free for noncommercial use:** any noncommercial purpose, and use by a
652
652
  charitable organization, educational institution, public research
@@ -0,0 +1 @@
1
+ 1.6.3
@@ -905,6 +905,10 @@ class CodeGen(CallVisitor, ExprVisitor, StmtVisitor, TopLevelEmitter, SecurityEm
905
905
  self._security_calls: list[dict] = [self._normalize_security_call(item) for item in ctx.security_calls]
906
906
  # Current function parameter types (set during _emit_func_def)
907
907
  self._current_func_param_types: dict[str, str] = {}
908
+ # The emitted C++ type of each tuple-destructuring binding, so a field
909
+ # read can recognise a chart.point binding whose TypeSpec is a
910
+ # deliberate tombstone.
911
+ self._tuple_binding_cpp_types_by_name: dict[str, str] = {}
908
912
  self._current_func_param_specs: dict[str, "TypeSpec"] = {}
909
913
  # Copy-on-write lexical collection inventory for the function/method
910
914
  # currently being emitted. Activated by _emit_func_def and restored
@@ -507,16 +507,25 @@ class TypeInferer:
507
507
  def _default_for_spec(self, spec: TypeSpec | None) -> str:
508
508
  """Default initialiser for a TypeSpec; vector/map specs get ``T()``.
509
509
 
510
- UDT specs always brace-init (``T{}``) regardless of whether the UDT was
511
- declared in the current translation unit — imported / forward-declared
512
- UDTs would otherwise fall through to ``0`` which is type-incompatible.
510
+ A user type brace-inits its struct name when the type is declared in
511
+ this translation unit (an imported type is inlined before codegen).
512
+ An enum element defaults to the double ``na`` (its slot is a double);
513
+ an undeclared name is not a C++ type and falls back to its slot's
514
+ default.
513
515
  """
514
516
  if spec is not None and spec.kind == "udt" and spec.name:
515
517
  # Drawing handle default (P2): brace-init the C++ struct name
516
518
  # (Line{} = na handle), NOT the lowercase Pine name (line{}).
517
519
  if spec.name in DRAWING_TYPE_TO_CPP:
518
520
  return f"{DRAWING_TYPE_TO_CPP[spec.name]}{{}}"
519
- return f"{self._safe_name(spec.name)}{{}}"
521
+ if spec.name in getattr(self, "_enum_defs", ()):
522
+ # An enum's element slot is a double (``_type_spec_to_cpp``);
523
+ # the absent value is na<double>(), not the first member and
524
+ # not the integer sentinel, which a double does not carry.
525
+ return "na<double>()"
526
+ if spec.name in getattr(self, "_udt_defs", ()):
527
+ return f"{self._safe_name(spec.name)}{{}}"
528
+ return self._default_for_type(self._type_spec_to_cpp(spec))
520
529
  cpp_type = self._type_spec_to_cpp(spec)
521
530
  if cpp_type.startswith("std::vector") or cpp_type.startswith("PineMap"):
522
531
  return f"{cpp_type}()"
@@ -4047,7 +4056,9 @@ class TypeInferer:
4047
4056
  return "int"
4048
4057
  # format.* constants emit std::string literals (consumed by
4049
4058
  # pine_str_tostring); bare reads must declare std::string.
4050
- if ename == "format":
4059
+ if ename in ("format", "currency", "order"):
4060
+ return "std::string"
4061
+ if ename == "session" and node.member in ("regular", "extended"):
4051
4062
  return "std::string"
4052
4063
  if ename == "alert" and node.member in ALERT_FREQ_VALUES:
4053
4064
  return "std::string"
@@ -196,6 +196,50 @@ from .tables import (
196
196
  _merge_kwargs,
197
197
  )
198
198
 
199
+ # Pine member names the codegen has a lowering for somewhere. A method the
200
+ # type resolver cannot route back to one of these tables (a history read of a
201
+ # UDT collection field, for example) keeps its historical pass-through
202
+ # spelling; anything else is not a Pine method and must not become C++ text.
203
+ PINEFORGE_MEMBER_NAMES = frozenset(
204
+ ARRAY_METHODS
205
+ ) | frozenset(MAP_METHODS) | frozenset(MATRIX_METHODS) | frozenset(
206
+ ALL_DRAWING_METHODS
207
+ )
208
+
209
+
210
+ def _spec_for_cpp_param(cpp: str | None):
211
+ """A TypeSpec for an untyped parameter's emitted C++ type, if known.
212
+
213
+ Only ``std::string`` is resolved: it carries C++ members of its own, so a
214
+ Pine method name that collides (``copy``, ``size``, ``clear``) must not
215
+ pass through. A numeric parameter has no such members; a collection
216
+ parameter is resolved by its own spec before this fallback.
217
+ """
218
+ if cpp == "std::string":
219
+ return TypeSpec.primitive("string")
220
+ return None
221
+
222
+
223
+ def _member_name_has_lowering(recv_spec, name: str) -> bool:
224
+ """Whether ``name`` is a Pine method of a receiver of ``recv_spec``.
225
+
226
+ A resolved receiver admits only its own namespace's table: a string has no
227
+ Pine methods, so a name like ``size`` or ``copy`` must not reach
228
+ ``std::string``. An unresolved receiver keeps the historical pass-through
229
+ for any Pine method name.
230
+ """
231
+ if recv_spec is None:
232
+ return name in PINEFORGE_MEMBER_NAMES
233
+ if recv_spec.kind == "array":
234
+ return name in ARRAY_METHODS
235
+ if recv_spec.kind == "map":
236
+ return name in MAP_METHODS
237
+ if recv_spec.kind == "matrix":
238
+ return name in MATRIX_METHODS
239
+ if recv_spec.kind == "udt" and recv_spec.name in DRAWING_TYPE_TO_CPP:
240
+ return name in ALL_DRAWING_METHODS
241
+ return False
242
+
199
243
 
200
244
  def _parse_pine_datestring_ms(text: str) -> int | None:
201
245
  """Parse a Pine ``timestamp(dateString)`` literal to Unix milliseconds.
@@ -310,6 +354,25 @@ class CallVisitor:
310
354
  # Function-call dispatch
311
355
  # ------------------------------------------------------------------
312
356
 
357
+ def _reject_unknown_element_type(self, node, element_spec) -> None:
358
+ """Refuse an element type that is not a type this unit can name.
359
+
360
+ The support checker normally refuses it; a switch arm downgrades that
361
+ error to a warning, so the emitter checks again and never defaults an
362
+ undeclared name.
363
+ """
364
+ if (element_spec is not None and element_spec.kind == "udt"
365
+ and element_spec.name
366
+ and element_spec.name not in self._udt_defs
367
+ and element_spec.name not in self._enum_defs
368
+ and element_spec.name not in DRAWING_TYPE_TO_CPP
369
+ and element_spec.name not in ("table", "polyline")):
370
+ full = element_spec.name
371
+ self._codegen_error(
372
+ node,
373
+ f"{full}(...) is not implemented in PineForge runtime.",
374
+ )
375
+
313
376
  def _udt_method_call_emit_name(self, fi, node: FuncCall) -> str:
314
377
  """Resolve a UDT method call through the ordinary UDF clone graph."""
315
378
  base = self._emit_udt_method_cpp_name(fi)
@@ -1794,6 +1857,17 @@ class CallVisitor:
1794
1857
  self._array_method_args(meth, arg_nodes, recv_spec),
1795
1858
  recv_spec, node,
1796
1859
  )
1860
+ if recv_spec is None:
1861
+ # A builtin namespace's constant lowers to a string
1862
+ # temporary; its emitted type is what the member
1863
+ # would be called on.
1864
+ recv_spec = _spec_for_cpp_param(self._infer_type(obj))
1865
+ if not _member_name_has_lowering(recv_spec, meth):
1866
+ full = meth
1867
+ self._codegen_error(
1868
+ node,
1869
+ f"{full}(...) is not implemented in PineForge runtime.",
1870
+ )
1797
1871
  args = ", ".join(raw_args)
1798
1872
  if meth == "delete":
1799
1873
  meth = "_delete_"
@@ -1943,6 +2017,16 @@ class CallVisitor:
1943
2017
  force_stage=self._binds_fresh_array_to_reference(
1944
2018
  fi_u, rest_nodes, first_param=1),
1945
2019
  )
2020
+ if recv_spec is None:
2021
+ recv_spec = _spec_for_cpp_param(
2022
+ self._current_func_param_types.get(obj.name)
2023
+ ) or _spec_for_cpp_param(self._infer_type(obj))
2024
+ if not _member_name_has_lowering(recv_spec, meth_raw):
2025
+ full = meth_raw
2026
+ self._codegen_error(
2027
+ node,
2028
+ f"{full}(...) is not implemented in PineForge runtime.",
2029
+ )
1946
2030
  args = ", ".join(self._visit_expr(a) for a in node.args)
1947
2031
  recv = self._visit_expr(obj)
1948
2032
  meth = meth_raw
@@ -2166,6 +2250,7 @@ class CallVisitor:
2166
2250
  spec = self._widen_array_spec_for_name(target, spec)
2167
2251
  cpp_type = self._type_spec_to_cpp(spec)
2168
2252
  elem_spec = spec.element if spec.element is not None else TypeSpec.primitive("float")
2253
+ self._reject_unknown_element_type(node, elem_spec)
2169
2254
  init_default = self._default_for_spec(elem_spec)
2170
2255
  if node.args:
2171
2256
  size_arg = self._visit_expr(node.args[0])
@@ -2214,6 +2299,7 @@ class CallVisitor:
2214
2299
  spec = declared
2215
2300
  spec = self._widen_array_spec_for_name(target, spec)
2216
2301
  elem_spec = spec.element
2302
+ self._reject_unknown_element_type(node, elem_spec)
2217
2303
  for a in node.args:
2218
2304
  self._warn_narrow_int_element(a, spec, a)
2219
2305
  elems = ", ".join(
@@ -2738,6 +2824,13 @@ class CallVisitor:
2738
2824
  if func_name == "new":
2739
2825
  targs = self._template_args_from_call(node)
2740
2826
  elem_spec = self._type_spec_from_hint_name(targs[0]) if targs else TypeSpec.primitive("float")
2827
+ if elem_spec is None:
2828
+ full = targs[0]
2829
+ self._codegen_error(
2830
+ node,
2831
+ f"{full}(...) is not implemented in PineForge runtime.",
2832
+ )
2833
+ self._reject_unknown_element_type(node, elem_spec)
2741
2834
  args_e = [self._visit_expr(a) for a in node.args]
2742
2835
  rows = args_e[0] if args_e else "0"
2743
2836
  cols = args_e[1] if len(args_e) > 1 else "0"
@@ -2952,6 +3045,16 @@ class CallVisitor:
2952
3045
  hint="Check the spelling; this namespace may not be supported "
2953
3046
  "by PineForge.",
2954
3047
  )
3048
+ elif namespace is not None:
3049
+ # A UDT name is a value type, not a namespace: its constructor,
3050
+ # copy and typed methods return above. Anything left is a call
3051
+ # the codegen cannot lower; emitting it raw would write the
3052
+ # user's type name as a C++ namespace qualifier.
3053
+ full = f"{namespace}.{func_name}"
3054
+ self._codegen_error(
3055
+ node,
3056
+ f"{full}(...) is not implemented in PineForge runtime.",
3057
+ )
2955
3058
 
2956
3059
  # Generic function call (user-defined or unknown)
2957
3060
  # Determine which params are series (need Series<double> arg, not scalar)
@@ -3126,7 +3229,8 @@ class CallVisitor:
3126
3229
  # Mirror Pine default `timeframe.period` instead of hard-coding 15m.
3127
3230
  all_args.append("script_tf_")
3128
3231
  ordered_arg_nodes.append(None)
3129
- prefix = f"{namespace}::" if namespace else ""
3232
+ # Every non-null namespace is refused above (unknown namespace, or a
3233
+ # member call on a user type), so the emitted head is never qualified.
3130
3234
  # Use safe name for user-defined functions to avoid member name collision
3131
3235
  emit_name = self._func_safe_name(func_name) if func_name in self._func_names else func_name
3132
3236
  # Per-call-site variant: if this function has TA/series calls, call the correct variant
@@ -3155,7 +3259,7 @@ class CallVisitor:
3155
3259
  # Inside a per-call-site variant: propagate call-site index to
3156
3260
  # sub-functions that also have variants (for state isolation)
3157
3261
  emit_name = f"{self._func_safe_name(func_name)}_cs{self._active_call_site_idx}"
3158
- call_head = f"{prefix}{emit_name}"
3262
+ call_head = emit_name
3159
3263
  if namespace is None and func_name in self._func_names:
3160
3264
  return self._ordered_user_call_expr(
3161
3265
  call_head,
@@ -1177,14 +1177,44 @@ class ExprVisitor:
1177
1177
  or name in self._current_func_locals
1178
1178
  or name in self._udt_var_types
1179
1179
  ):
1180
- safe = self._call_site_var_name(
1181
- node.object, self._safe_name(name)
1180
+ # A member the codegen has no lowering for. A user type's
1181
+ # field is a real C++ member (chart.point keeps its fields
1182
+ # this way); a builtin-backed receiver has no Pine member, so
1183
+ # writing the name raw would read arbitrary C++ state.
1184
+ recv_spec = self._type_spec_from_expr(node.object)
1185
+ tuple_cpp = getattr(
1186
+ self, "_tuple_binding_cpp_types_by_name", {}
1187
+ ).get(name)
1188
+ point = (
1189
+ (recv_spec is not None and recv_spec.name == "chart.point")
1190
+ or self._infer_type(node.object) == "ChartPoint"
1191
+ or tuple_cpp == "ChartPoint"
1192
+ )
1193
+ if point and node.member in ("time", "index", "price"):
1194
+ safe = self._call_site_var_name(
1195
+ node.object, self._safe_name(name)
1196
+ )
1197
+ return f"{safe}.{node.member}"
1198
+ full = f"{name}.{node.member}"
1199
+ self._codegen_error(
1200
+ node,
1201
+ f"{full}(...) is not implemented in PineForge runtime.",
1182
1202
  )
1183
- return f"{safe}.{node.member}"
1184
1203
  if name not in self.ctx.series_vars:
1185
1204
  # Unknown identifier — likely an enum value
1186
1205
  return f'std::string("{self._cpp_string_escape(node.member)}")'
1187
- return f"{obj}.{node.member}"
1206
+ recv_spec = self._type_spec_from_expr(node.object)
1207
+ point = (
1208
+ (recv_spec is not None and recv_spec.name == "chart.point")
1209
+ or self._infer_type(node.object) == "ChartPoint"
1210
+ )
1211
+ if point and node.member in ("time", "index", "price"):
1212
+ return f"{obj}.{node.member}"
1213
+ full = f"{node.member}"
1214
+ self._codegen_error(
1215
+ node,
1216
+ f"{full}(...) is not implemented in PineForge runtime.",
1217
+ )
1188
1218
 
1189
1219
  def _operand_na_kind(self, node, cpp_type: str) -> str | None:
1190
1220
  """Classify a relational operand by the ``na`` sentinel it can carry.
@@ -315,6 +315,11 @@ class StmtVisitor:
315
315
  # unrelated same-named global/callable UDT must not target-
316
316
  # type a later ``name := na`` as ``State{}``.
317
317
  self._lexical_udt_types[name] = None
318
+ self._tuple_binding_cpp_types_by_name[name] = (
319
+ tuple_cpp_types[index]
320
+ if index < len(tuple_cpp_types)
321
+ else "double"
322
+ )
318
323
  if (getattr(self, "_active_func_name", None) is not None
319
324
  and not self._decl_binding_is_series(
320
325
  id(node), name
@@ -650,6 +650,11 @@ class Parser:
650
650
 
651
651
  def _parse_type_hint_string(self) -> str:
652
652
  """Parse primitive, UDT, array<T>, map<K,V>, or postfix-array (``T[]``) hints."""
653
+ # A type hint is a type grammar, never an arbitrary token's value: a
654
+ # string or number here would reach the emitted C++ type position.
655
+ if (self._current().type not in TYPE_KEYWORDS
656
+ and self._current().type != TokenType.IDENT):
657
+ self._consume(TokenType.IDENT) # raises a located ParseError
653
658
  base = self._advance().value
654
659
  # Library type qualified by its import alias: ``lib.Type``.
655
660
  while self._check(TokenType.DOT) and self._peek().type == TokenType.IDENT:
@@ -676,8 +681,12 @@ class Parser:
676
681
  continue
677
682
  if tok.type == TokenType.COMMA:
678
683
  parts.append(",")
679
- else:
684
+ elif (tok.type in TYPE_KEYWORDS
685
+ or tok.type in (TokenType.IDENT, TokenType.DOT)):
680
686
  parts.append(str(tok.value))
687
+ else:
688
+ # A string/number/operator inside <...> is not a type.
689
+ self._consume(TokenType.IDENT)
681
690
  self._advance()
682
691
  base = f"{base}<{''.join(parts)}>"
683
692
 
@@ -712,11 +721,20 @@ class Parser:
712
721
  break
713
722
  depth -= 1
714
723
  current.append(">")
715
- elif tok.type == TokenType.COMMA and depth == 0:
716
- args.append("".join(current).strip())
717
- current = []
718
- else:
724
+ elif tok.type == TokenType.COMMA:
725
+ # A comma at depth 0 separates arguments; inside a nested
726
+ # <...> it belongs to that type (map<string, float>).
727
+ if depth == 0:
728
+ args.append("".join(current).strip())
729
+ current = []
730
+ else:
731
+ current.append(",")
732
+ elif (tok.type in TYPE_KEYWORDS
733
+ or tok.type in (TokenType.IDENT, TokenType.DOT)):
719
734
  current.append(str(tok.value))
735
+ else:
736
+ # Template arguments are type names, not literal text.
737
+ self._consume(TokenType.IDENT)
720
738
  self._advance()
721
739
  return args
722
740
 
@@ -740,6 +758,12 @@ class Parser:
740
758
  return i + 1 < len(self.tokens) and self.tokens[i + 1].type == TokenType.LPAREN
741
759
  elif tt in (TokenType.NEWLINE, TokenType.EOF_TOKEN) and depth > 0:
742
760
  return False
761
+ elif tt not in TYPE_KEYWORDS and tt not in (
762
+ TokenType.IDENT, TokenType.DOT, TokenType.COMMA,
763
+ ):
764
+ # Not the type grammar: this '<' is an ordinary comparison,
765
+ # not the opening of template arguments.
766
+ return False
743
767
  i += 1
744
768
  return False
745
769
 
@@ -18,7 +18,7 @@ A script's imports resolve only through its own manifest, never through the
18
18
  case-wide directory alone: otherwise a probe that pins no library would
19
19
  transpile on a shard neighbour's pin, and measure differently by case
20
20
  composition. ``transpile()`` is handed the source text, not a slug (the frozen
21
- verifier, pineforge-lab 3bac0b7b ``scripts/verify-engine-local.py:1698``, calls
21
+ campaign verifier (commit 3bac0b7b, ``scripts/verify-engine-local.py:1698``) calls
22
22
  ``transpile((d / "strategy.pine").read_text())``), so the manifest is found by
23
23
  content: the one ``requests.json`` whose ``probe.strategySha256`` is the sha256
24
24
  of the script. That sha is of the strategy file's bytes, and ``read_text()``
@@ -1932,6 +1932,27 @@ class SupportChecker:
1932
1932
  self._err(node, f"array.{name}(...) is not implemented in PineForge runtime.")
1933
1933
  self._visit_children(node)
1934
1934
  return
1935
+ if ns == "array" and name in ("new", "from"):
1936
+ # The element type names a C++ type in the emitted default
1937
+ # initialiser; it must be a Pine type, never arbitrary text.
1938
+ targs = (getattr(node.callee, "annotations", None) or {}).get("template_args") or []
1939
+ targs = [str(t).replace(" ", "") for t in targs]
1940
+ if targs:
1941
+ t = targs[0]
1942
+ allowed_prim = {"float", "int", "bool", "string", "color"}
1943
+ allowed_udt = {
1944
+ "line", "label", "box", "linefill", "chart.point",
1945
+ "table", "polyline",
1946
+ }
1947
+ if ("<" not in t and ">" not in t
1948
+ and t not in allowed_prim
1949
+ and t not in self._user_types
1950
+ and t not in self._user_enums
1951
+ and t not in allowed_udt):
1952
+ full = t
1953
+ self._err(node, f"{full}(...) is not implemented in PineForge runtime.")
1954
+ self._visit_children(node)
1955
+ return
1935
1956
  if ns == "map" and name not in SUPPORTED_MAP:
1936
1957
  self._err(node, f"map.{name}(...) is not implemented in PineForge runtime.")
1937
1958
  self._visit_children(node)
@@ -1 +0,0 @@
1
- 1.6.2-rc.1