Skip to content

Refactor parse tree for function arguments. #7645

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

Merged
merged 3 commits into from
Jul 15, 2025
Merged

Conversation

cristianoc
Copy link
Collaborator

Put the label and type together, so in future it will be possible to represent a function of several arguments with a list.

Put the label and type together, so in future it will be possible to represent a function of several arguments with a list.
Copy link

pkg-pr-new bot commented Jul 15, 2025

Open in StackBlitz

rescript

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/win32-x64

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

commit: ec0e8c2

@cristianoc cristianoc requested review from zth, cknitt and Copilot July 15, 2025 09:24
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the representation of function arguments by combining the label and type into a single arg record and updating all related pattern matches, constructors, and functions across the codebase.

  • Introduce a new arg record to encapsulate an argument’s lbl and typ.
  • Refactor Tarrow and Ptyp_arrow definitions and all pattern matches/constructors to use arg instead of separate label/type fields.
  • Update parser, syntax, typedtree, typecore, and helper modules to align with the new arrow type structure.

Reviewed Changes

Copilot reviewed 48 out of 48 changed files in this pull request and generated no comments.

File Description
tools/src/tools.ml Update collectSignatureTypes to extract arg.typ and return type from new Tarrow
compiler/syntax/src/res_parsetree_viewer.ml Refactor Ptyp_arrow patterns to match on arg.lbl and arg.typ
compiler/ml/types.mli Add new arg type and update Tarrow signature
compiler/ml/typedtree.mli Add arg record and update Ttyp_arrow to use arg
Comments suppressed due to low confidence (2)

compiler/ml/types.mli:60

  • [nitpick] The type name arg is very generic and may conflict with other contexts; consider renaming it to something more descriptive like arrow_arg or func_arg to improve clarity.
and arg = {lbl: Noloc.arg_label; typ: type_expr}

compiler/syntax/src/res_parsetree_viewer.ml:14

  • This new Ptyp_arrow pattern should be covered by unit tests for arrow_type to ensure unlabelled arrows are handled correctly after the refactor.
     ptyp_desc = Ptyp_arrow {arg = {lbl = Nolabel} as arg; ret};

Copy link
Member

@cknitt cknitt left a comment

Choose a reason for hiding this comment

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

Put the label and type together, so in future it will be possible to represent a function of several arguments with a list.

That would be great, now that curried mode is gone! 👍

@cristianoc cristianoc merged commit f26d5c9 into master Jul 15, 2025
27 checks passed
@cristianoc cristianoc deleted the type_argument branch July 15, 2025 14:14
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.

2 participants