rescript-lang / rescript-lang/rescript
Improve error message when adding type to generic application
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 7.5k
- Forks
- 485
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 55
Description
Consider
module WebAPI = {
module DOMAPI = {
type element
}
}
let elementRefCorrect : React.ref<Nullable.t<WebAPI.DOMAPI.element>> = React.useRef(Nullable.null)
let elementRef = React.useRef<WebAPI.DOMAPI.element>(Nullable.null)
In F#, you can specify the React.useRef<WebAPI.DOMAPI.element> syntax.
I can live with the fact that ReScript doesn't have the same syntax as F#.
But the error message is very confusing:
Type Errors
[E] Line 8, column 30:
The value element can't be found in WebAPI.DOMAPI
The type does exists, whatever I'm going for syntax-wise is the issue here.
Could we improve this?
Thoughts @zth?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ReScript Try reproducer in the issue and trace the compiler's type-error reporting for the React.useRef generic application. The work is done when this invalid syntax produces a diagnostic that explains the syntax problem instead of incorrectly saying WebAPI.DOMAPI.element cannot be found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100