Parser: an attribute or doc comment in front of a `{...` spread type changes how it is read
維護者通常 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
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
rescript-lang/rescript 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 74/100
rescript-lang/rescript#9135 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 74/100
rescript-lang/rescript#9132 ·
維護者通常 1 天內回覆
-
Printed type declarations drop @tag, @notUndefined and runtime annotations可能已有人在做 @cknitt 今天認領。 未關閉
難度 4/5 1-2 天 新手友好度 25/100
rescript-lang/rescript#9134 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 35/100
rescript-lang/rescript#9130 · 1 則留言 ·
維護者通常 1 天內回覆
-
Dev dependencies interacting可能已有人在做 @CarlOlson 於 3 天前認領。 未關閉
難度 4/5 1-2 天 新手友好度 25/100
rescript-lang/rescript#9089 · 1 則留言 ·
維護者通常 1 天內回覆
查看 rescript-lang/rescript 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 4 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
CanadaHonk/porffor#426 ·
-
難度 2/5 1-3 小時 新手友好度 77/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
compiler-rt:asan llvm:transforms
難度 2/5 1-3 小時 新手友好度 72/100
llvm/llvm-project#236682 ·
維護者通常 1 天內回覆