Compiler 0.3.1 silently changes "\n" to "n" in string literals

Aperta
#73 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
compilers

Direzione di ricerca

Start by locating the string literal parsing and code generation entry points in the compiler, then reproduce with the provided repro.rx and compile.mjs example using @reactivescript/[email protected]. Check how the \n escape is represented through compilation; done means the generated separator evaluates to U+000A and the issue's reproduction no longer changes the split result.

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

Descrizione

With @reactivescript/[email protected], compiling a newline separator changes its meaning without reporting a diagnostic.

Reproduction

Install the compiler in a Node.js project:

npm install --save-exact @reactivescript/[email protected]

Create repro.rx:

source text := ""

export default component Probe() {
  lines = text.split("\n")
  <pre>{lines.length}</pre>
}

Create compile.mjs and run node compile.mjs:

import { app } from "@reactivescript/compiler";
import { resolve } from "node:path";

const result = JSON.parse(app(resolve("repro.rx"), "dom"));

if (!result.modules) {
  throw new Error(JSON.stringify(result));
}

for (const module of Object.values(result.modules)) {
  console.log(module.code);
}

Actual output

The generated computation contains:

const v$lines = __rt.memo("lines", (__prev) => v$text()?.split("n"), undefined);

The separator is the letter n (U+006E), rather than a newline (U+000A). Compilation succeeds without reporting a diagnostic.

Expected behavior

The generated separator should evaluate to U+000A, preserving the semantics of .split("\n").

For example, given the JavaScript string "first\nsecond":

// Expected
["first", "second"]

// Actual with the generated separator
["first\nseco", "d"]

Impact

This caused incorrect rendering of single-line error summaries in an application. Diagnosing it required inspecting the generated JavaScript. Moving the string processing into an imported TypeScript helper worked around the issue.

Environment

  • @reactivescript/compiler: 0.3.1
  • Target: dom
  • Node.js: v24.14.1
  • Platform: macOS, arm64

Reproduced again on November 15, 2026. Confirmed for \n; other escape sequences have not been tested.

Lingua principale
TypeScript
Stelle
127
Fork
7
Merge medio
15h 42m
PR unite (30g)
63

Preparare l'ambiente

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 solidjs/reactivescript

Tutte le issue di solidjs/reactivescript

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.