rescript format: aborts on a syntax error, unstable output, raw compiler errors

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

维护者通常 1 天内回复

@cknitt 已经在做这个了。

开始于 2026年11月6日。

  • #9249 来自 @cknitt —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
56/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
ocaml
领域
cli, tooling

调研方向

Start in rewatch-ocaml/format.ml, especially the referenced lines 113, 116, 142–143, 148, 200, and 209; reproduce the listed cases with ReScript 13.0.0-alpha.8. Check formatting behavior for syntax errors, output ordering and paths, duplicate arguments, invalid inputs, and --stdin errors. Done means each case reports all files and useful errors consistently, with deterministic unique paths and <stdin> shown for stdin errors.

由索引模型根据 Issue 内容生成。

描述

Problems with rescript format. All reproduce with rescript 13.0.0-alpha.8 (found while reviewing #9238); paths are in rewatch-ocaml/.

  • One file with a syntax error aborts the run. In a project with unformatted files and one file containing let x =, rescript format --check lists some files, then Error formatting <path>/B.res: with the syntax error, exit 1, and no summary. Without --check, some of the other files are left unformatted (with 40 unformatted files, 26–33 remained, varying per run). format.ml:142-143 raises inside the job callback, which stops the whole job graph. Format and report every file, then fail.

  • --check output order is nondeterministic, and paths are inconsistent. With 8 unformatted files, six runs of rescript format --check listed them in six different orders: each line is printed when its job finishes (format.ml:148). In project mode the paths are absolute; for explicit file arguments they are relative (format.ml:113, :209). Sort the list and print paths relative to the current directory.

  • Duplicate arguments are counted twice. rescript format --check src/F.res src/F.res lists the file twice and reports The 2 files listed above need formatting (format.ml:209).

  • Invalid arguments surface raw compiler errors.

    • rescript format src/Missing.res: Error formatting src/Missing.res: (trailing space), then We've found a bug for you!, _none_, I/O error: …: No such file or directory.
    • rescript format src and rescript format README.md: Error formatting src: don't know what to do with src.

    Nothing checks existence or extension before calling the compiler; format.ml:116 prefixes the compiler's stderr, which starts with a newline.

  • --stdin errors name a temporary file. echo 'let x =' | rescript format --stdin .res reports the syntax error at /tmp/rescript-format-7546c4.res:1:8-2:0 (format.ml:200); it should say <stdin>.

主要语言
OCaml
星标
7.5k
派生
485
平均合并
16 小时 51 分钟
30 天内合并 PR
268

环境准备

在 Codespaces 中打开

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

从这里开始

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

rescript-lang/rescript 的其他 Issue

查看 rescript-lang/rescript 的全部 Issue

相似的 Issue

更多 CLI Issue

把新 issue 发到你的邮箱

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