Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Parser: an attribute or doc comment in front of a `{...` spread type changes how it is read

未關閉
#9,122 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
1-2 天
新手友好度
55/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
ocaml
領域
compilers

研究方向

Start by reading the lookahead in res_core.ml and the referenced context in #9115, which keeps the current behaviors. Reproduce the table with bsc -bs-no-builtin-ppx -only-parse -dparsetree to trace how prefixes affect {... classification. Done means prefixes no longer change the classification, both reported syntax errors are fixed, and the compatibility change has a changelog entry.

由索引模型根據 Issue 內容生成。

描述

A type body starting with {... can be a record spread or an object spread. Without a prefix, the parser reads it as a record unless a quoted field follows. With an attribute or a doc comment in front, it takes a different path, so the prefix changes what the declaration means or makes it a syntax error.

Checked on master at 85f31fbb15 with bsc -bs-no-builtin-ppx -only-parse -dparsetree:

type t = … no prefix @attr /** d */
{...base, y: int} record syntax error record
{...base} record object type record
{...base, "y": int} object type object type syntax error

The same holds after private, e.g. type t = private @attr {...base, y: int} is a syntax error.

Cause: after an attribute, the lookahead in res_core.ml treats {... as the start of a type expression (object type); after a doc comment, the record path is taken unconditionally. #9115 (for #9106) keeps both behaviours as they are, so nothing master accepts changes there.

Expected: the prefix doesn't matter, and {... is classified as without one. That fixes both syntax errors, but it also turns @attr {...base} from an object type into a record, which changes code that compiles today, so it needs a changelog entry.

🤖 Generated with Claude Code

主要語言
OCaml
星號
7.5k
分支
484
平均合併
21 小時 9 分鐘
30 天內合併 PR
255

環境準備

在 Codespaces 中開啟

在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

rescript-lang/rescript 的其他 Issue

查看 rescript-lang/rescript 的全部 Issue

相似的 Issue

更多 Compilers Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。