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

Formatter drops comments in dict patterns, variant spread patterns and dict literal spreads

クローズ
#8,820 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

関連するプルリクエストがすでにマージされています。

  • #8850 @cknitt による — マージ済み

評価

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

調査の方向性

Start with res_comments_table.ml and res_printer.ml at the locations linked in the issue, then review the comment fixtures under tests/syntax_tests/data/printer/comments/. Reproduce with the provided cm.res command and add fixture cases for dict patterns and variant spread patterns. Done means formatting preserves every listed comment and the fixtures catch losses on the first print.

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

説明

Found by adversarial experiments on semantic analysts.

What is broken

The formatter deletes comments in these positions:

  • Dict pattern key: | dict{"a" /* k */: b} → | dict{"a": b}
  • Dict pattern value: | dict{"a": /* c */ a} → | dict{"a": a} (the record pattern {a: /* c */ a} keeps its comment)
  • Empty dict pattern: | dict{/* e */} → | dict{}
  • Variant spread pattern: | .../* c */ t → | ...t
  • Polymorphic variant type pattern: | #.../* c */ t → | #...t
  • Dict literal with a spread: an own-line comment before the first row after a spread is dropped (/* x */ on the same line is kept)

Reproduction

cm.res:

let f = d =>
  switch d {
  | dict{"a" /* k */: b} => b
  | dict{"a": /* c */ a} => a
  | dict{/* e */} => 0
  | _ => 1
  }
type t = A | B
type u = | ...t | C
let g = x =>
  switch x {
  | .../* c */ t => 0
  | #.../* c */ t => 0
  | C => 1
  }
let b = dict{
  ...base,
  // first
  "a": 1,
}
./_build/default/compiler/syntax/cli/res_cli.exe cm.res

Observed: every comment above is missing from the output. Expected: each comment is printed.

Where

No comment fixture covers dict patterns or variant spread patterns (tests/syntax_tests/data/printer/comments/). The roundtrip test compares the first formatting with the second, so a comment lost on the first print passes. The fix should add these cases to the comment fixtures.

Introduced by

The same output is produced at ece8b148, before the dict pattern and variant spread nodes existed. The current code comes from b081cd19c (#8749) and bffd18e7b (#8742).

Impact

Running the formatter silently deletes user comments.

主要言語
ReScript
スター
7.5k
フォーク
483
平均マージ
1日 1時間
マージ済み PR(30日)
120

環境構築

Codespaces で開く

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

はじめの一歩

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

rescript-lang/rescript のほかの issue

rescript-lang/rescript の issue をすべて見る

似ている issue

Testing & QA の issue をもっと見る

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

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