Skip to content

Conversation

zth
Copy link
Member

@zth zth commented Sep 18, 2025

We do not support spreads in dict literals yet, but one day we will. This gives a proper error for the spread in the meantime.

Copy link
Contributor

@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 adds a dedicated error message for dict literal spreads, which are not yet supported in ReScript. The change improves user experience by providing a clear, specific error message when developers attempt to use spread syntax (...) in dict literals.

Key changes:

  • Adds specific error handling for spread syntax in dict literals
  • Provides clear error message indicating the feature is not yet supported
  • Includes test case to verify the error behavior

Reviewed Changes

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

File Description
res_core.ml Adds error message constant and parsing logic to detect and handle dict spread syntax
dict_spread.res Test case containing invalid dict spread syntax
dict_spread.res.txt Expected error output for the test case
CHANGELOG.md Documents the improvement in the Polish section

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

Copy link

pkg-pr-new bot commented Sep 18, 2025

Open in StackBlitz

rescript

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: 30c8562

...b}` wouldn't make sense, as `b` would override every field of `a` \
anyway."

let dict_expr_spread = "Dict literals do not support spread (`...`) yet."
Copy link
Member

@nojaf nojaf Sep 18, 2025

Choose a reason for hiding this comment

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

Bit of a stretch, but we could sneak in a link to a GitHub issue folks can upvote. That gives an indication how many people have tried this.

@zth zth merged commit d3539ef into master Sep 19, 2025
25 checks passed
@zth zth deleted the dict-spread-error branch September 19, 2025 07:01
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