Skip to content
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

Improve error message for duplicate labels #6415

Merged
merged 1 commit into from
Sep 27, 2023

Conversation

zth
Copy link
Collaborator

@zth zth commented Sep 27, 2023

No description provided.

@zth zth requested a review from cristianoc September 27, 2023 19:16
@zth
Copy link
Collaborator Author

zth commented Sep 27, 2023

cc @DZakh

Copy link
Contributor

@DZakh DZakh left a comment

Choose a reason for hiding this comment

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

❤️

Comment on lines +2001 to +2004
| Duplicate_label (s, None) ->
fprintf ppf "The field @{<info>%s@} is defined several times in this record. Fields can only be added once to a record." s
| Duplicate_label (s, Some recordName) ->
fprintf ppf "The field @{<info>%s@} is defined several times in the record @{<info>%s@}. Fields can only be added once to a record." s recordName
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose the error message might be used for objects as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Objects are a bit trickier, and needs a general overhaul. Doesn't seem like overwriting object fields is an error at all, although you can't change their type of course.

@@ -1998,8 +1998,10 @@ let report_error ppf = function
fprintf ppf "A type parameter occurs several times"
| Duplicate_constructor s ->
fprintf ppf "Two constructors are named %s" s
| Duplicate_label s ->
fprintf ppf "Two labels are named %s" s
| Duplicate_label (s, None) ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious: when does this case fire?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Inline records, I believe.

@zth zth merged commit ccea327 into master Sep 27, 2023
@zth zth deleted the error-message-duplicate-labels branch September 27, 2023 19:47
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.

3 participants