Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Formatter silently changes whitespace and operators inside multiline string literals

未关闭
#1,245 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
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
平均合并
4 小时 5 分钟
30 天内合并 PR
116

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

InauguralSystems/EigenScript 的其他 Issue

查看 InauguralSystems/EigenScript 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。