rescript-lang / rescript-lang/rescript
[bug] @as can create type problems
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 7.5k
- Forks
- 485
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 55
Description
this is a really stupid example that would likely never happen in real-life (but hey, you give a million monkeys infinite amount of time with keyboards...). if it DOES happen, it'll cost some developer x amount of hours to debug. it's kinda far out there, but not as far as @as("RE_EXN_ID)"...
right now i'm just having fun trying to break things to find bugs and i stumbled upon this.
exception Foo({@as("Error") e: string})
let s: string = try throw(Foo({e: "foo"})) catch {
| Foo({e}) => e
}
Console.log(s == "foo")
Console.log(s)
as you can imagine, this logs false and then an error object. i'm not sure what the takeaway is here.. possibly:
a) call me an idiot and close this
b) come up with some way to prohibit use of or warn on using @as("Error") for inlined exception records (yeah, kinda niche...)
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 by running the inline exception-record reproduction in the issue and confirm how @as("Error") affects the caught value. Then trace the compiler handling for @as on inline exception records. The issue does not define whether the desired result is a warning, prohibition, or different runtime behavior, so the expected outcome needs clarification before implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100