Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Formatter silently changes whitespace and operators inside multiline string literals

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

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

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

評価

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

調査の方向性

Start in src/fmt.c around lines 333–344 and inspect how fix_spacing handles physical lines, then review multiline literal handling in src/lexer.c around line 485. Extend tests/test_fmt.sh with the reproducer, blank lines, operator/comment-like text, and a single-line control. Done means formatted output preserves literal bytes and ordinary source whitespace normalization still works through the shared formatting path.

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

説明

area:lint-tooling bug found-by:code-review kind:silent-wrong

The formatter edits the contents of a valid multiline string: it changes indentation, removes trailing spaces, and inserts spaces around apparent operators inside the literal. The resulting program still exits successfully but produces different data. --fmt --write persists that corruption; LSP formatting uses the same function.

Exact reproduction

Create a fixture with literal newlines inside its quoted string. The middle line has two leading and two trailing spaces:

python3 - <<'PYFIXTURE'
from pathlib import Path
Path('multiline.eigs').write_text('value is "start\n  a+b  \nend"\nprint of value\n')
PYFIXTURE
eigenscript multiline.eigs
eigenscript --fmt multiline.eigs > formatted.eigs
eigenscript formatted.eigs

Both executions and formatting exit 0. Exact stdout, shown as escaped strings:

before: "start\n  a+b  \nend\n"
after:  "start\n    a + b\nend\n"

The formatter emits this source:

value is "start
    a + b
end"
print of value

Cause

The lexer accepts the multiline literal and retains these bytes. src/fmt.c:333–344 strips leading/trailing whitespace from every physical line before knowing whether it is inside a string. fix_spacing also starts each physical line with string state cleared, so a+b is treated as source code.

This breaks the formatter's string-preservation behavior already checked for single-line strings by tests/test_fmt.sh (string content not modified). The existing corpus parseability check cannot detect this case: both programs parse.

Regression acceptance

  • The formatted reproducer's exact stdout equals the original, including leading/trailing spaces and newlines inside the literal.
  • Cover blank lines and operator/comment-looking text inside multiline strings, alongside a normal single-line string control.
  • Keep ordinary source whitespace normalization working outside literals; verify the shared formatting path preserves literal data.

Distinct from the operator-table fixes in #729/#750.

Verification

Confirmed with a fresh default make build of b91768e23c5a874a64e76e4af9ab291e6aa49983 in a clean isolated worktree. The original, formatter, and transformed program were executed separately with inherited EIGS_* variables removed; exit status and output were captured for each.

主要言語
C
スター
3
フォーク
7
平均マージ
3時間 58分
マージ済み PR(30日)
105

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

InauguralSystems/EigenScript のほかの issue

InauguralSystems/EigenScript の issue をすべて見る

似ている issue

C の issue をもっと見る

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

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