rescript-lang / rescript-lang/rescript
You should not be able to cast to a private record/variant
Open
@tsnobip is already working on this.
Since May 31, 2026.
- Dominant language
- OCaml
- Stars
- 7.5k
- Forks
- 485
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 55
Description
Today, this compiles without any warning or error (cf playground):
module Foo = {
type t = private {foo: int}
}
module Bar = {
type t = {...Foo.t}
}
let bar = {Bar.foo: 9}
let foo = (bar :> Foo.t)
which doesn't make sense because private records/variants are precisely meant to avoid instantiation.
This should IMO at least raise a warning.
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.
Assessment
This issue has not been assessed yet.