Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Preserve @as decorator on record fields when creating interface#7779

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@mediremi
Copy link
Member

Closes#7611

@mediremimediremi marked this pull request as ready for reviewAugust 21, 2025 08:58
Copy link
Contributor

CopilotAI 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 fixes an issue where the@as decorator on record fields was not being preserved when creating interface files. The change ensures that type declarations with attributes are copied verbatim to maintain their decorators.

  • Added logic to detect and preserve attributes (like@as) on type declarations
  • Enhanced the AttributesUtils module with anisEmpty function
  • Updated the interface creation process to copy type declarations with attributes verbatim

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

FileDescription
analysis/src/CreateInterface.mlCore logic to detect attributes and preserve type declarations verbatim
tests/analysis_tests/tests/src/CreateInterface.resTest case with external function and record type using@as decorator
tests/analysis_tests/tests/src/expected/CreateInterface.res.txtExpected output showing preserved@as decorators
CHANGELOG.mdDocumentation of the bug fix

Tip: Customize your code reviews with copilot-instructions.md.Create the file orlearn how to get started.

sigItemToString
(Printtyp.tree_of_type_declaration id typeDecl resStatus)
in
Buffer.add_string buf (indent^ newItemStr^"\n"));

Choose a reason for hiding this comment

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

[nitpick] The conditional logic should be inverted to reduce nesting. Consider using early return pattern:if AttributesUtils.isEmpty attributes then (* normal processing *) else (* verbatim copy *).

Copilot uses AI. Check for mistakes.

(ifnot (AttributesUtils.isEmpty attributes)then
(* Copy the type declaration verbatim to preserve attributes*)
Buffer.add_string buf ((lines|>String.concat"\n")^"\n")

Choose a reason for hiding this comment

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

String concatenation with^ creates intermediate strings. Consider usingBuffer.add_string for each line separately orString.concat "\n" without the additional concatenation.

Suggested change
Buffer.add_string buf ((lines|>String.concat"\n")^"\n")
Array.iter (funline ->Buffer.add_string buf line;Buffer.add_char buf'\n') lines

Copilot uses AI. Check for mistakes.
@pkg-pr-new
Copy link

pkg-pr-newbot commentedAug 21, 2025
edited
Loading

Open in StackBlitz

rescript

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/win32-x64

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

commit:7a4127f

let attributes=AttributesUtils.make linesin

(ifnot (AttributesUtils.isEmpty attributes)then
(* Copy the type declaration verbatim to preserve attributes*)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this work in theelse branch too? Can we always copy verbatim? Or what's the tradeoff here?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I've removed theelse branch since every type declaration should be valid in an interface file when copied verbatim 👍 The only tradeoff I can think of is that we'll be copying any non-doc comments within the declaration

@mediremimediremi merged commit9efa7e2 intorescript-lang:masterAug 21, 2025
27 checks passed
@mediremimediremi deleted the as-decorator-create-interface branchAugust 21, 2025 13:56
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

@cristianoccristianoccristianoc approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

CreateInterface.command doesn't copy over@as decorators in records

2 participants

@mediremi@cristianoc

[8]ページ先頭

©2009-2025 Movatter.jp