-
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
Add support for functions in untagged variants. #6279
Conversation
This was done at speed: need to double check that there are no corner cases missing. Fixes #6278
@@ -298,6 +311,8 @@ module DynamicChecks = struct | |||
typeof e != number | |||
| ArrayType -> | |||
not (is_array e) | |||
| FunctionType -> | |||
typeof e != function_ |
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.
Functions cannot overlap with literals so this case should be OK.
@@ -341,9 +356,8 @@ module DynamicChecks = struct | |||
let add_runtime_type_check ~tag_type ~(block_cases: block_type list) x y = | |||
let has_array() = Ext_list.exists block_cases (fun t -> t = ArrayType) in | |||
match tag_type with | |||
| Untagged IntType | |||
| Untagged StringType | |||
| Untagged FloatType -> typeof y == x |
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.
This seems OK as functions can't overlap with int, string, float, object, array.
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.
Awesome, this is great!
Works as expected! |
This was done at speed: need to double check that there are no corner cases missing.
Fixes #6278
TODO: