-
Notifications
You must be signed in to change notification settings - Fork 455
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
Untagged variants powered by instanceof #6383
Conversation
This implements support for using
Adding more to this list as we go. One restriction here is that we need anything using |
Follow up work from this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't approve as I figure as the author.
But it's approved.
Left some comments.
jscomp/core/lam_compile.ml
Outdated
S.string_switch ?default ?declaration (E.typeof e) clauses in | ||
~else_:([build_if_chain rest]) | ||
| (Ast_untagged_variants.Untagged (InstanceType instanceType), {J.switch_body}) :: rest -> | ||
S.if_ (E.instanceof e (E.js_global (Ast_untagged_variants.Instance.to_string instanceType))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See js_exp_make: the array case emits different code.
Perhaps put the emission logic in one place shared so it's done only once for instances (and the array special cased only once in that logic)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cristianoc can you check this commit, is this along the lines of what you had in mind? e687695
Logic is now only in emit_check
.
Will it work even with opaque types? Sounds like a magic 🙌 |
Depends on what you mean. It'll work with a few select built in opaque types, but not any opaque type. Aliases is about if you for example have |
No description provided.