{"record":{"id":"55b14c0b3407ec28","repo":"can1357/oh-my-pi","slug":"intersection-of-leftdomain-and-rightdomain-i","errorCode":null,"errorMessage":"intersection of ${leftDomain} and ${rightDomain} is unsatisfiable","messagePattern":"intersection of (.+?) and (.+?) is unsatisfiable","errorType":"exception","errorClass":"OmpTypeError","httpStatus":null,"severity":"error","filePath":"packages/omptype/src/type.ts","lineNumber":2138,"sourceCode":"\tif (a.k === \"tuple\" && b.k === \"tuple\") return intersectTuples(a, b);\n\tif (a.k === \"tuple\" && b.k === \"array\") return intersectTupleWithArray(a, b);\n\tif (a.k === \"array\" && b.k === \"tuple\") return intersectTupleWithArray(b, a);\n\tif (a.k === \"instance\" && b.k === \"instance\") {\n\t\tif (a.ctor === b.ctor || a.ctor.prototype instanceof b.ctor) return a;\n\t\tif (b.ctor.prototype instanceof a.ctor) return b;\n\t\tthrow new OmpTypeError(`intersection of ${a.expected} and ${b.expected} is unsatisfiable`);\n\t}\n\tif (a.k === b.k && [\"null\", \"undefined\", \"boolean\", \"bigint\", \"symbol\", \"anyobject\"].includes(a.k)) return a;\n\tif (\n\t\t(a.k === \"object\" && (b.k === \"array\" || b.k === \"tuple\")) ||\n\t\t(b.k === \"object\" && (a.k === \"array\" || a.k === \"tuple\"))\n\t) {\n\t\treturn { k: \"intersection\", members: [a, b] };\n\t}\n\tconst leftDomain = domainOf(a);\n\tconst rightDomain = domainOf(b);\n\tif (leftDomain !== undefined && rightDomain !== undefined && leftDomain !== rightDomain) {\n\t\tthrow new OmpTypeError(`intersection of ${leftDomain} and ${rightDomain} is unsatisfiable`);\n\t}\n\tif (a.k === \"anyobject\" && rightDomain === \"object\") return b;\n\tif (b.k === \"anyobject\" && leftDomain === \"object\") return a;\n\tconst members = [...(a.k === \"intersection\" ? a.members : [a]), ...(b.k === \"intersection\" ? b.members : [b])];\n\treturn { k: \"intersection\", members };\n}\n\n/** Reduce parsed unions/intersections to their observable semantic form. */\nfunction normalizeIR(ir: IR): IR {\n\tswitch (ir.k) {\n\t\tcase \"intersection\": {\n\t\t\tconst members = ir.members.map(normalizeIR);\n\t\t\tif (members.length === 0) return { k: \"unknown\" };\n\t\t\treturn members.slice(1).reduce(intersect, members[0]);\n\t\t}\n\t\tcase \"union\": {\n\t\t\tconst members: IR[] = [];\n\t\t\tlet changed = false;","sourceCodeStart":2120,"sourceCodeEnd":2156,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/omptype/src/type.ts#L2120-L2156","documentation":"Generic domain-conflict check near the end of the intersection algorithm: if both operands have a defined value domain (from domainOf) and the domains differ, no value can belong to both, so the intersection is rejected. This is the catch-all for kind combinations not handled by the earlier structural branches.","triggerScenarios":"intersect(string(), number()); intersect(lit(1), string()); intersecting any two types whose domains (e.g. 'string' vs 'number', 'object' vs 'string') disagree and have no earlier special case.","commonSituations":"Wiring the wrong schema field into an intersection (name/positional mixup); a refactor changed one operand's base kind; intersecting an optional/undefined-domain type with a string-constrained type.","solutions":["Ensure both operands share the same base domain before intersecting","Inspect each operand with the library's type inspection to confirm the intended kinds","Fix operand ordering/arguments if a mixup passed the wrong type","Catch OmpTypeError and log both expected domains to identify the mismatch"],"exampleFix":"// before\nintersect(string(), number());\n// after\nintersect(string().url(), string().min(1));","handlingStrategy":"validation","validationCode":"// compare kinds before intersecting\nfunction domainsCompatible(a, b) {\n  const da = domainOf(a), db = domainOf(b);\n  return da === undefined || db === undefined || da === db;\n}","typeGuard":"const isOmpTypeError = (e: unknown): e is OmpTypeError => e instanceof OmpTypeError;","tryCatchPattern":"try {\n  const t = intersect(a, b);\n} catch (err) {\n  if (err instanceof OmpTypeError && err.message.includes('domain')) {\n    logger.warn('intersecting incompatible domains', { left: describe(a), right: describe(b) });\n  } else throw err;\n}","preventionTips":["Inspect both operands' kinds before intersecting; intersect only same-domain types","Fix argument order/passing — most domain conflicts come from supplying the wrong schema","Add a schema-construction test that exercises each intersection path"],"tags":["types","domain","intersection","omptype"],"backgroundTag":"unsatisfiable-type-intersection","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}