Skip to content

Misc fixes and optimizations#149

Merged
alaa-eddine merged 4 commits intodevfrom
misc-fixes-and-optimizations
Mar 6, 2026
Merged

Misc fixes and optimizations#149
alaa-eddine merged 4 commits intodevfrom
misc-fixes-and-optimizations

Conversation

@alaa-eddine
Copy link
Collaborator

Added

  • Method-Call Syntax on Drawing Instances: LineObject, LabelObject, and BoxObject now carry delegate setter/getter methods directly on the instance (e.g., myLine.set_x2(x), myBox.set_right(r), myLabel.set_text(t)). Each delegate forwards to the owning helper so the plot sync (_syncToPlot) fires correctly. Enables Pine Script patterns where drawing objects stored in UDTs or arrays are mutated via method syntax.
  • Gradient Fill (fill()): Added support for Pine Script's gradient fill signature — fill(plot1, plot2, top_value, bottom_value, top_color, bottom_color). The FillHelper detects the gradient form (third argument is a number) and stores per-bar top_value/bottom_value/top_color/bottom_color data for the renderer.
  • Typed Generic Function Parameters: The Pine Script parser now correctly handles generic type annotations in function parameter lists (e.g., array<float> src, map<string, float> data). Previously these caused parse errors.

Fixed

  • UDT Thunk Resolution for Drawing Object Fields: When a var UDT instance contains fields initialised with factory calls (e.g., line.new(...), box.new(...)), those fields are now correctly resolved as thunks on bar 0 inside initVar. Previously the thunk-wrapped factory results were stored as raw functions in the UDT field, causing the drawing object to never be created.
  • Typed Array Type Inference for Object Types: inferValueType() no longer throws "Cannot infer type from value" when called with an object (e.g., a LineObject or BoxObject). It now returns PineArrayType.any, allowing array<line> and similar typed arrays to work correctly.
  • Non-Computed Namespace Property Access in $.param(): Fixed ExpressionTransformer incorrectly wrapping namespace constant accesses (e.g., label.style_label_down, line.style_dashed) in $.get() calls when they appeared inside function arguments. The transformer now detects non-computed member access on NAMESPACES_LIKE identifiers and leaves them untransformed.
  • histbase Type in PlotOptions: Fixed the histbase field in the PlotOptions TypeScript type from boolean to number, matching the actual Pine Script plot(histbase=50) signature.
  • For-Loop MemberExpression Recursion: Fixed user variable identifiers inside method calls in for loops (e.g., lineMatrix.rows()) not being transformed. The MemberExpression visitor in transformForStatement now recurses into the object node after transformation so nested identifiers are correctly resolved.
  • Multiline and / Comparison Expressions: Fixed the Pine Script parser dropping continuation lines in and/&& chains and comparison expressions spanning multiple lines. skipNewlines(true) is now called after the operator.
  • matrix.inv() — Full NxN Support: Rewrote matrix.inv() from a 2×2-only implementation to Gauss-Jordan elimination with partial pivoting, supporting any square matrix. Singular matrices (pivot < 1e-14) return a NaN matrix.
  • matrix.pinv() — Real Pseudoinverse: Rewrote matrix.pinv() from a placeholder stub to a correct Moore-Penrose pseudoinverse: square → inv(), tall (m > n) → (AᵀA)⁻¹Aᵀ, wide (m < n) → Aᵀ(AAᵀ)⁻¹.
  • array.min() / array.max() Performance: Added an O(N) fast path for the common nth=0 case instead of always sorting O(N log N).
  • array.median(), percentile_linear_interpolation(), percentile_nearest_rank() Performance: Single-pass copy-and-validate optimizations.
  • isPlot() with Undefined Title: Fixed isPlot() to accept plot objects that have _plotKey but no title property (e.g., fill plots created via callsite ID), preventing fill() from misidentifying its arguments (contribution by @dcaoyuan, #142).
  • Duplicate map in CONTEXT_PINE_VARS: Removed an accidental duplicate 'map' entry from settings.ts.

Fix for typed arrays handling
Fix Box/Line instances member functions access
Fix : non computed properties access
@alaa-eddine alaa-eddine merged commit 1f2cec2 into dev Mar 6, 2026
1 check passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant