Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use Typ.arrows after the refactoring of arrow types. #7662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

cristianoc
Copy link
Collaborator

No description provided.

Reworks the construction of maker function arguments and accessor value descriptions for type declarations. The maker function now accumulates argument types in a list and builds the final function type using Ast_helper.Typ.arrows. Accessor generation is clarified and setter types for mutable fields are constructed with explicit argument lists. This improves readability and maintainability of the code.
@@ -79,14 +79,16 @@ let handle_tdcl light (tdcl : Parsetree.type_declaration) :
Ext_list.exists label_declarations (fun x ->
Ast_attributes.has_bs_optional x.pld_attributes)
in
let setter_accessor, make_type, labels =
let setter_accessor, maker_args, labels =
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Typ.arrows here. Understand the logic behind the arity, fix it if necessary, and pass the correct number of arguments at the right place so the arity ends up being right.

Read file: compiler/frontend/ast_derive_abstract.ml

Ran tool

Ran tool

Ran tool

Read file: compiler/ml/parsetree.ml

Read file: compiler/frontend/ast_derive_abstract.ml

Read file: compiler/frontend/ast_derive_abstract.ml

Ran tool

Ran tool

Ran tool

Ran tool

Read file: compiler/frontend/ast_derive_abstract.ml

I've replaced all ambiguous record literals with explicit Parsetree.arg annotations and ensured we always build argument lists and setter types using Typ.arrows. This removes ambiguity around the attrs field and guarantees that arity is set only once—by Typ.arrows, which automatically puts the total argument count on the outermost node.

Key updates:

  1. Initial maker-argument seed now uses an explicitly-typed unit argument list.
  2. Each field now adds an explicitly-typed Parsetree.arg to that list.
  3. The final make_type is built with a single Typ.arrows call, so arity equals the full argument count.
  4. Getter types stay at arity = 1 (single arrow), unchanged.
  5. Setter types for mutable fields rebuilt via Typ.arrows, giving arity = 2 and no manual inner arity flags.
  6. All record literals for arguments are annotated with : Parsetree.arg, resolving the previous “unbound record field attrs” errors.

With these changes, every place now relies on Typ.arrows, ensuring correct arity placement and cleaner code.

Copy link

pkg-pr-new bot commented Jul 18, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7662

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7662

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7662

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7662

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7662

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7662

commit: d08107c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant