jsonToOpenUI drops parentheses on right operand of equal precedence ($a - ($b - $c) becomes $a - $b - $c)

Aperta
#1,463 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@ShryukGrandhi ci sta già lavorando.

Dal 23/10/2026.

  • #1464 di @ShryukGrandhi — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
typescript

Direzione di ricerca

The issue points to jsonToOpenUI in @openuidev/lang-core and says serializeBinOpChild receives an unused side argument. Read that serializer and its existing tests, then add a regression case for a same-precedence right operand such as $a - ($b - $c). Done means serialization preserves the parentheses; pull request 1464 is already open against this issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug
jsonToOpenUI (in @openuidev/lang-core) drops the parentheses around a right-hand operand that has the same precedence as its parent operator. The parser is left-associative, so the serialized text means something different from the original expression. $a - ($b - $c) is written out as $a - $b - $c, which parses back as ($a - $b) - $c. The same thing happens with / and % (for example, $a / ($b * $c) becomes $a / $b * $c).

To Reproduce

import { jsonToOpenUI } from "@openuidev/lang-core";

const node = {
  type: "element",
  typeName: "Title",
  props: {
    text: {
      k: "BinOp",
      op: "-",
      left: { k: "StateRef", n: "$a" },
      right: {
        k: "BinOp",
        op: "-",
        left: { k: "StateRef", n: "$b" },
        right: { k: "StateRef", n: "$c" },
      },
    },
  },
  partial: false,
  hasDynamicProps: true,
};

jsonToOpenUI(node, library);
// => 'root = Title($a - $b - $c)'

With $a = 10, $b = 4, $c = 1, the original expression evaluates to 7. The serialized one evaluates to 5.

Expected behavior
root = Title($a - ($b - $c)). The right operand should keep its parentheses whenever its precedence is less than or equal to the parent's.

Actual behavior
root = Title($a - $b - $c). The parentheses are only kept when the child's precedence is strictly lower. serializeBinOpChild already receives a side argument but never uses it.

Environment

  • Package: @openuidev/lang-core (main @ 334faff2)
  • Node 24, macOS arm64

Additional context
I have a small fix with a regression test ready if that helps.

Lingua principale
TypeScript
Stelle
10k
Fork
698
Merge medio
1g 6h
PR unite (30g)
158

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di thesysdev/openui

Tutte le issue di thesysdev/openui

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.