mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-24 06:14:01 +08:00
* Expand static Effect support across common APIs * Preserve compiler parity across expanded Effect patterns * Fix compiler regressions exposed by Effect coverage * Bound shared type conversion traversal * Clarify conversion contracts and tidy fixtures * Run every Effect fixture in CI shards * Preserve inferred array assignments in concurrent Effect programs * Record inferred array fixture compiler ordering
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
class YieldableError extends Error {}
|
|
const Failure = (function () {
|
|
const key = Symbol("args");
|
|
const named = {
|
|
BaseFailure: class extends YieldableError {
|
|
constructor(args) {
|
|
super(args.message);
|
|
Object.assign(this, args);
|
|
Object.defineProperty(this, key, { value: args });
|
|
}
|
|
},
|
|
};
|
|
return named.BaseFailure;
|
|
})();
|
|
function tagged(tag) {
|
|
const named = { TaggedFailure: class extends Failure { _tag = tag; } };
|
|
named.TaggedFailure.prototype.name = tag;
|
|
return named.TaggedFailure;
|
|
}
|
|
class Rejected extends tagged("Rejected") {}
|
|
const error = new Rejected({ message: "invalid", detail: 42 });
|
|
console.log(error.name, error.message, error.detail, error._tag, error instanceof Error);
|
|
console.log(error.toString(), Object.hasOwn(error, "name"));
|
|
error.name = "Custom";
|
|
console.log(error.name, error.toString(), Object.hasOwn(error, "name"));
|
|
console.log(Object.prototype.propertyIsEnumerable.call(error, "name"));
|
|
const other = new Rejected({ message: "next" });
|
|
console.log(other.name, other.toString(), Object.hasOwn(other, "name"));
|