-
Notifications
You must be signed in to change notification settings - Fork 457
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
Optimize literal checks in untagged variants #6393
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is still a thing I'd like us to have a look at eventually. It's about untagged variants sometimes producing excessive code. Example: let v = JSON.Array([String("hello")])
let x = x =>
switch x {
| JSON.Array(arr) =>
arr
->Array.filterMap(a =>
switch a {
| String(s) => Some(s)
| _ => None
}
)
->Array.join(",")
| _ => "-"
} Produces this JS: import * as Core__Array from "./stdlib/core__Array.js";
var v = ["hello"];
function x(x$1) {
if (!Array.isArray(x$1) && (x$1 === null || typeof x$1 !== "object") && typeof x$1 !== "number" && typeof x$1 !== "string" && typeof x$1 !== "boolean" || !Array.isArray(x$1)) {
return "-";
} else {
return Core__Array.filterMap(x$1, (function (a) {
if (!Array.isArray(a) && (a === null || typeof a !== "object") && typeof a !== "number" && typeof a !== "string" && typeof a !== "boolean" || typeof a !== "string") {
return ;
} else {
return a;
}
})).join(",");
}
} 2 main things:
This might not be trivial to fix and is probably a property of how the pattern matching engine is written, but I figured I'd log it anyway so we have it in the tracker. |
No description provided.
The text was updated successfully, but these errors were encountered: