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

Multiple locations of duplicated definition for better user experience #5695

Closed
mununki opened this issue Sep 24, 2022 · 3 comments · Fixed by #6199
Closed

Multiple locations of duplicated definition for better user experience #5695

mununki opened this issue Sep 24, 2022 · 3 comments · Fixed by #6199
Assignees
Milestone

Comments

@mununki
Copy link
Member

mununki commented Sep 24, 2022

The JSX internal representation and user both can define the props type in the same scope. In order to show a better error message, multiple locations of props type need to be handled specially. Even generalizing this issue, multiple locations of duplicated definitions could be handled for a better user experience.

@mununki
Copy link
Member Author

mununki commented Sep 24, 2022

module StringSet =
  Set.Make(struct type t = string let compare (x:t) y = String.compare x y end)

let check cl loc set_ref name =
  if StringSet.mem name !set_ref
  then raise(Error(loc, Env.empty, Repeated_name(cl, name)))
  else set_ref := StringSet.add name !set_ref

Isn't Set enough? Does it need to be changed map?

@cristianoc cristianoc transferred this issue from rescript-lang/syntax Sep 24, 2022
@cristianoc cristianoc added this to the v11.0 milestone Sep 24, 2022
@cristianoc
Copy link
Collaborator

This is not specific to JSX, just motivated by it.

@Minnozz
Copy link
Contributor

Minnozz commented Sep 24, 2022

An easy solution may be to emit a separate warning with the other location. Although I believe warnings are never shown when there is an error?

Other languages often use hints attached to an error, where hints can have locations too ("Previous definition was here:")

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 a pull request may close this issue.

3 participants