Skip to content

fix(transpiler): + / - on display constants are set operations - #309

Merged
alexgrover merged 1 commit into
devfrom
fix/display-arithmetic
Sep 15, 2026
Merged

alexgrover merged 1 commit into
devfrom
fix/display-arithmetic

Conversation

@alexgrover

@alexgrover alexgrover commented Sep 14, 2026

Copy link
Copy Markdown
Member

Problem

Pine's display.* constants are a set type — + is the union of two displays and - removes one display's surfaces from another (display.all - display.price_scale is the reference manual's own example). PineTS keeps them as member-name strings, so:

  • display.all - display.price_scale evaluated to NaN (hosts then fell back to their default — typically showing the plot everywhere);
  • display.all + display.none produced the raw concatenation 'allnone', in source order, with duplicates (display.pane + display.pane'panepane').

Fix

  • transformDisplayArithmetic — a post-process pass beside transformEqualityChecks — rewrites a + / - BinaryExpression with a display.<member> operand (a literal member, an expression this pass already rewrote, or a variable combined with a member) to display.__union(a, b) / display.__minus(a, b), built through ASTFactory. Numeric arithmetic elsewhere is untouched (pinned by test).
  • displayUnion / displayMinus (Types.ts) compute the surface set and report it as the canonical concatenation of member names in the order pane, data_window, status_line, price_scale — 'all' / 'none' for the full / empty set. This is the shape + on the string enum already produced, so the display.* enum stays string-valued and hosts parsing member names keep working.
expression result
display.all - display.none all
display.all + display.none / display.none + display.all all
display.none - display.all none
display.all - display.price_scale panedata_windowstatus_line
display.pane + display.data_window (either order) panedata_window
display.all - display.pane - display.price_scale data_windowstatus_line
display.pane + display.pane pane

Tests

tests/namespaces/plot/display-arithmetic.test.ts — written failing first (NaN / 'allnone' / 'data_windowpane'), now green: the table above, chained and variable forms, hline / plotshape / input arguments, defaults untouched, and a transpiled-code check that only display expressions are routed. Full suite: 175 files / 1873 tests passing (3 pre-existing skips).

Docs: docs/api-coverage/types.md (display combination semantics), CHANGELOG.md under Unreleased.

Downstream

The Vela Pine engine (LuxAlgo/Vela-pinets#36) already parses this output; once this ships it can bump its pinets range so - becomes a guarantee.


Note

Low Risk
Scoped transpiler rewrite and display helpers; fixes incorrect plot visibility strings without touching auth, data, or strategy logic.

Overview
Fixes Pine parity for combining display.* values: + and - now behave as set union and set difference instead of JavaScript string concatenation or NaN.

A new transpiler post-pass, transformDisplayArithmetic, rewrites + / - when either side is a display.<member> (including chained expressions and variables) into display.__union / display.__minus. Runtime helpers in Types.ts parse the canonical string form, compute surfaces in order pane → data_window → status_line → price_scale, and emit 'all' / 'none' or the joined member names hosts already understand. Plain literals and unrelated numeric math are unchanged.

Tests cover plot, hline, plotshape, and input display args; docs note set semantics in types.md.

Reviewed by Cursor Bugbot for commit 8c5cefa. Bugbot is set up for automated code reviews on this repo. Configure here.

Pine's `display.*` values form a set type: `+` unions two displays and `-`
removes one's surfaces from the other (`display.all - display.price_scale`).
The runtime keeps them as member-name strings, so native `-` yielded NaN and
`+` a raw concatenation in source order (`display.all + display.none` →
'allnone').

A post-process pass, `transformDisplayArithmetic`, routes `+` / `-` with a
`display.*` operand — literal members, chained expressions, or a variable
combined with a member — to `display.__union` / `display.__minus`, which
compute the set and report it as the canonical concatenation of member names
(pane, data_window, status_line, price_scale; 'all' / 'none' for the full /
empty set), the shape hosts already parse. `display.all - display.none` →
'all', `display.none - display.all` → 'none', `display.pane + display.pane` →
'pane'. Plain member values and the enum are unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cursor

cursor Bot commented Sep 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_080129f1-075c-476e-a44f-aa8fc8eb9660)

@alexgrover
alexgrover merged commit 125ccee into dev Sep 15, 2026
2 of 3 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 15, 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