Skip to content

[bug] @as can create type problems #7957

@tx46

Description

@tx46

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...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions