Repository navigation
Conversation
Changelog🐛 Bug fix
Semantic Diff1 commit · Full page ✏️ Parse attributes after
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9115 +/- ##
=======================================
Coverage 81.46% 81.46%
=======================================
Files 460 460
Lines 64675 64684 +9
=======================================
+ Hits 52689 52698 +9
Misses 11986 11986
🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9115 |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a8d70f94b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
5a8d70f to
6883c20
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6883c20c44
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
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
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Kbf3gGkPma9LAZimuQjnrP
Signed-off-by: Christoph Knittel <[email protected]>
6883c20 to
bea1cbc
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
type t = private @attr {x: int}andtype z = /** d */ intwere both rejected, althoughtype t = @attr {x: int},type t = private {x: int}andtype z = @attr intparse.After
= private, an attribute counts as the start of a type expression, so@attr {x: int}was parsed as a manifest and the record failed. After=, a doc comment was always sent to the type representation parser, which then expected a constructor, so/** d */ int,{"a": int},(int, int),[#A]andM.tfailed.The lookahead that already decided between representation and manifest for an attribute after
=is now a shared helper, used for both attributes and doc comments, after=and after= private: past attributes and doc comments, a record,..,|or a constructor makes a representation, anything else a manifest. Attributes and doc comments before a private record or..go on the type declaration, as for the non-private forms (#8919).Tests: new cases in the parser fixture
typedefinition/typeRepresentation.res(attributes and doc comments afterprivatebefore a record,.., constructors, a type and an object; doc comments after=beforeint, an object, a tuple, a polymorphic variant,M.tandM.t = A | B) and in the printer fixturetypeDef/attributes.res, which also checks that the newly accepted forms round-trip.Not changed:
type t = private {x: {y: int}}(a nested record afterprivate) is still rejected, with or without an attribute; that is a separate limitation of the private record path. A spread keeps its old meaning: after a doc comment{...base, y: int}is a record declaration, after an attribute an object type, so@attr {...base, y: int}and/** d */ {...base, "y": int}are still rejected, as on master; tracked in #9122.A differential run against master over 672 declarations (no prefix, one or two doc comments, an attribute, and both orders of doc comment and attribute, times 28 bodies such as constructors, variant and record spreads, records, objects,
..,int,M.t = A,'aandint => int; with and withoutprivate; in .res and .resi) gives the same parse tree for every declaration master accepts. The only changes are forms master rejected: a doc comment before a type expression or object, and an attribute afterprivatebefore constructors, a record or...Fixes #9106
🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gGkPma9LAZimuQjnrP