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

Deprecate @raises in favor of @throws in reanalyze#7932

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

Copy link
Contributor

CopilotAI commentedOct 2, 2025
edited
Loading

Overview

This PR deprecates the@raises decorator in reanalyze in favor of@throws to better align with JavaScript and ReScript terminology. The change maintains full backward compatibility while guiding users toward the new decorator.

Motivation

ReScript usesthrow for raising exceptions (notraise), so using@throws for the exception analysis decorator provides better consistency with the language's terminology and makes it more intuitive for developers.

Changes

Core Reanalyze

  • Exception.ml: Updated to accept both@throws/@throw (new) and@raises/@raise (deprecated) decorators
  • Log_.ml: Updated warning messages to suggest@throws instead of@raises

Example warning message before:

myFunction might raise Not_found and is not annotated with @raises(Not_found)

Example warning message after:

myFunction might raise Not_found and is not annotated with @throws(Not_found)

IDE/Editor Support

  • CompletionDecorators.ml: Added@throws decorator with full documentation and marked@raises as deprecated with a clear migration message

Documentation & Examples

  • Updated all test files to use@throws decorator
  • Updated expected test outputs to reflect new terminology
  • UpdatedStdlib_JSON runtime library to use@throws

Backward Compatibility

No breaking changes. Existing code using@raises will continue to work without modification. The implementation accepts all variants:

// NEW - Recommended@throws(MyException)letmyFunction= ()=>throw(MyException)// OLD - Still works but deprecated@raises(MyException)letmyFunction= ()=>throw(MyException)

IDE users will see a deprecation notice when using@raises, guiding them to use@throws instead, but their code will function identically.

Migration

Users can migrate at their own pace. Simply replace@raises with@throws:

-@raises(Not_found)+@throws(Not_found) let findValue = key => Dict.getExn(myDict, key)

Both decorators accept the same syntax:

  • Single exception:@throws(MyException)
  • Multiple exceptions:@throws([E1, E2, E3])
Original prompt

deprecate the use of@raises in reanalyze and use@throws instead.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.

chatgpt-codex-connector[bot] reacted with thumbs up emoji
- Update reanalyze Exception.ml to accept both@throws and@raises decorators- Update warning messages to use@throws terminology- Add@throws decorator to completion with documentation- Mark@raises as deprecated in completion- Update all test files to use@throws instead of@raises- Update expected test outputs to reflect@throws terminology- Update Stdlib_JSON to use@throws instead of@raisesCo-authored-by: tsnobip <2479216+tsnobip@users.noreply.github.com>
CopilotAI changed the title[WIP] deprecate the use of@raises in reanalyze and use@throws instead.Deprecate @raises in favor of @throws in reanalyzeOct 2, 2025
CopilotAI requested a review fromtsnobipOctober 2, 2025 09:45
Copilot finished work on behalf oftsnobipOctober 2, 2025 09:45
@pkg-pr-new
Copy link

pkg-pr-newbot commentedOct 2, 2025
edited
Loading

Open in StackBlitz

rescript

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit:501eaa2

@tsnobiptsnobip marked this pull request as ready for reviewOctober 2, 2025 10:49
@tsnobip
Copy link
Member

fixes#7680.

@tsnobiptsnobip requested a review fromcknittOctober 2, 2025 10:59
Copy link
Member

@cknittcknitt left a comment

Choose a reason for hiding this comment

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

We should check the terminology - are there still any other places using "raise" instead of "throw"

@cknitt
Copy link
Member

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. You're on a roll.

ℹ️ 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 👍.

@tsnobiptsnobipforce-pushed thecopilot/fix-ffd931b9-0aba-4a57-b568-72a4365d3180 branch from2dc9cc9 to4f5313aCompareOctober 3, 2025 07:16
@tsnobiptsnobip requested a review fromcknittOctober 3, 2025 07:52
@tsnobiptsnobipforce-pushed thecopilot/fix-ffd931b9-0aba-4a57-b568-72a4365d3180 branch from01d9c83 to501eaa2CompareOctober 3, 2025 07:57
tsnobip added a commit to rescript-lang/rescript-lang.org that referenced this pull requestOct 3, 2025
Copy link
Member

@cknittcknitt left a comment

Choose a reason for hiding this comment

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

LGTM.
Maybe@cristianoc would like to have a look, too?

@tsnobiptsnobip merged commit11cde90 intomasterOct 3, 2025
25 checks passed
@tsnobiptsnobip deleted the copilot/fix-ffd931b9-0aba-4a57-b568-72a4365d3180 branchOctober 3, 2025 13:25
fhammerschmidt pushed a commit to rescript-lang/rescript-lang.org that referenced this pull requestOct 3, 2025
* Document the deprecation of@raises over@throwsFollowing the changes introduced byrescript-lang/rescript#7932* document exception analysis in editor-plugins* format* update libraries set up to use exception analysis* remove the outdated functor example for exception analysis* rename List.hd to List.head (its name in Stdlib)* rename functors to module functions
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@cknittcknittcknitt approved these changes

@tsnobiptsnobipAwaiting requested review from tsnobip

@cristianoccristianocAwaiting requested review from cristianoc

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@tsnobip@cknitt

[8]ページ先頭

©2009-2025 Movatter.jp