You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 799a82f
Browse filesBrowse the repository at this point in the historyBrowse files
Parse attributes after = private and a doc comment before a manifest (#9115)
Why:
`private @attr {x: int}` took the type expression path and rejected
the record, and a doc comment right after `=` always started a
constructor list, so `/** d */ int` failed. Both now use the
lookahead that attributes after `=` already had: past attributes and
doc comments, a record, `..`, `|` or constructor is a representation,
anything else a manifest.
AST modified (doc comment before a manifest):
Example:
type z = /** d */ int
Before (diagnostic):
Did you mean `Int` instead of `int`?
After (parse):
type_declaration "z"
ptype_kind =
Ptype_abstract
ptype_private = Public
ptype_manifest =
Some
core_type
attribute "res.doc"
…
Ptyp_constr "int"
Format modified (attribute after `private`):
Example:
type t = private @attr {x: int}
type u = private /** d */ int
Before (diagnostic):
An inline record type declaration is only allowed in a variant
constructor's declaration or nested inside of a record type declaration
After (rescript):
@attr type t = private {x: int}
type u = private /** d */ int
Review: Does a leading doc comment change any form that parsed before? No.
After a doc comment the lookahead keeps the representation for every
start the constructor and record parsers accept (`|`, a constructor,
`...base`, `{...`, a record, `..`); only starts they rejected, such as
`int`, `M.t`, `'a`, `(a, b)`, `[#A]`, `{.}` or `{"a": int}`, become a
manifest. A differential run over 672 declarations (prefixes x bodies,
with and without `private`, .res and .resi) gives the same tree as before
for every one that parsed.
Fixes#9106
Claude-Session: https://claude.ai/code/session_01Kbf3gGkPma9LAZimuQjnrP
Signed-off-by: Christoph Knittel <ck@cca.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
0 commit comments