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

Better error when trying to use a keyword as a record field#7784

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
zth merged 6 commits intomasterfromhint-keyword-as-record-field
Aug 22, 2025

Conversation

@zth
Copy link
Member

@zthzth commentedAug 22, 2025
edited
Loading

Closes#7579

Also adds error recovery so the parser can continue and spits out less irrelevant parse errors.

nojaf and mediremi reacted with heart emoji
@pkg-pr-new
Copy link

pkg-pr-newbot commentedAug 22, 2025
edited
Loading

Open in StackBlitz

rescript

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/win32-x64

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

commit:3d13dba

@zthzth marked this pull request as ready for reviewAugust 22, 2025 07:39
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 improves error handling when developers attempt to use language keywords as record field names in ReScript. The change provides clearer error messages and better error recovery to continue parsing after encountering such errors.

  • Adds helpful error messages suggesting alternatives (e.g.,type_) and the@as annotation for runtime compatibility
  • Implements error recovery to continue parsing and reduce cascading parse errors
  • Covers all record field contexts: type definitions, expressions, and patterns

Reviewed Changes

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

Show a summary per file
FileDescription
res_core.mlImplements keyword detection and recovery logic for record fields with improved error messages
recordFieldKeywordInType.resTest case for keyword usage in record type definitions
recordFieldKeywordInExpr.resTest case for keyword usage in record expressions
recordFieldKeywordInPattern.resTest case for keyword usage in record patterns
expected/*.txtExpected error outputs showing improved error messages and recovery
CHANGELOG.mdDocuments the enhancement in the changelog

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

|[] ->assertfalse
|hd ::tl ->List.fold_left (funps ->Longident.Ldot (p, s)) (Lident hd) tl

(* Recovers a keyword used as field name if it's probable that it's a full

Choose a reason for hiding this comment

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

[nitpick] The comment has inconsistent spacing. There should be a space after 'full' to maintain proper spacing before the line break.

Copilot uses AI. Check for mistakes.
|hd ::tl ->List.fold_left (funps ->Longident.Ldot (p, s)) (Lident hd) tl

(* Recovers a keyword used as field name if it's probable that it's a full
field name (not punning etc), by checking if there's a colon after it.*)

Choose a reason for hiding this comment

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

[nitpick] The comment should end the sentence with a period before the closing comment marker for consistency.

Copilot uses AI. Check for mistakes.
@zthzth removed the request for review fromcristianocAugust 22, 2025 07:42
@zthzth marked this pull request as draftAugust 22, 2025 07:42
Copy link
Collaborator

@cristianoccristianoc left a comment

Choose a reason for hiding this comment

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

Much cleaner.
Left some nitpick.

let keyword_txt=Token.to_string p.tokenin
let keyword_start= p.Parser.start_posin
let keyword_end= p.Parser.end_posin
let message=
Copy link
Collaborator

Choose a reason for hiding this comment

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

why identical message construction here and a few lines earlier?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Solved ina3870f7 (was just working on it when you commented).

@zthzthforce-pushed thehint-keyword-as-record-field branch from5ce8a8d toa3870f7CompareAugust 22, 2025 08:49
@zthzth marked this pull request as ready for reviewAugust 22, 2025 08:59
@zthzthenabled auto-merge (squash)August 22, 2025 09:00
@zthzth merged commitfc7226b intomasterAug 22, 2025
27 checks passed
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.

Improve error message when using keyword as field name

3 participants

@zth@cristianoc

[8]ページ先頭

©2009-2025 Movatter.jp