Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions compiler/ml/ast_untagged_variants.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ module Instance = struct
| Uint32Array
| Uint8Array
| Uint8ClampedArray
| Set
| Map
| WeakSet
| WeakMap
let to_string = function
| Array -> "Array"
| ArrayBuffer -> "ArrayBuffer"
Expand All @@ -39,6 +43,10 @@ module Instance = struct
| Uint32Array -> "Uint32Array"
| Uint8Array -> "Uint8Array"
| Uint8ClampedArray -> "Uint8ClampedArray"
| Set -> "Set"
| Map -> "Map"
| WeakSet -> "WeakSet"
| WeakMap -> "WeakMap"
end

type untagged_error =
Expand Down Expand Up @@ -256,6 +264,10 @@ let type_to_instanceof_backed_obj (t : Types.type_expr) =
| "Stdlib.Uint8ClampedArray.t" -> Some Uint8ClampedArray
| "Js_file.t" -> Some File
| "Js_blob.t" -> Some Blob
| "Stdlib.Set.t" -> Some Set
| "Stdlib.Map.t" -> Some Map
| "Stdlib.WeakSet.t" -> Some WeakSet
| "Stdlib.WeakMap.t" -> Some WeakMap
| _ -> None)
| _ -> None

Expand Down
16 changes: 16 additions & 0 deletions tests/tests/src/UntaggedVariants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,22 @@ async function classifyAll(t) {
console.log("DataView");
return;
}
if (t instanceof Set) {
console.log("Set");
return;
}
if (t instanceof Map) {
console.log("Map");
return;
}
if (t instanceof WeakSet) {
console.log("WeakSet");
return;
}
if (t instanceof WeakMap) {
console.log("WeakMap");
return;
}
switch (typeof t) {
case "string" :
console.log(t);
Expand Down
8 changes: 8 additions & 0 deletions tests/tests/src/UntaggedVariants.res
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ module AllInstanceofTypes = {
| BigInt64Array(BigInt64Array.t)
| BigUint64Array(BigUint64Array.t)
| DataView(DataView.t)
| Set(Set.t<string>)
| Map(Map.t<string, unknown>)
| WeakSet(WeakSet.t<string>)
| WeakMap(WeakMap.t<string, unknown>)

let classifyAll = async (t: t) =>
switch t {
Expand All @@ -437,6 +441,10 @@ module AllInstanceofTypes = {
| BigInt64Array(_) => Console.log("BigInt64Array")
| BigUint64Array(_) => Console.log("BigUint64Array")
| DataView(_) => Console.log("DataView")
| Set(_) => Console.log("Set")
| Map(_) => Console.log("Map")
| WeakSet(_) => Console.log("WeakSet")
| WeakMap(_) => Console.log("WeakMap")
}
}

Expand Down
Loading