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

オープン
#73 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
70/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript
領域
compilers

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
127
フォーク
7
平均マージ
15時間 42分
マージ済み PR(30日)
63

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

solidjs/reactivescript のほかの issue

solidjs/reactivescript の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。