use default

This commit is contained in:
sfja 2026-03-11 12:37:46 +01:00
parent 9d72188f48
commit 6b93bf0fc6
2 changed files with 9 additions and 5 deletions

View File

@ -94,8 +94,10 @@ class Expr {
return k.value;
case "Add":
return k.right.eval() + k.left.eval();
}
default:
k satisfies never; // compile time exhaustiveness check
throw new Error("unexhausted"): // run time exhaustiveness check
}
}
// ...
}
@ -195,14 +197,15 @@ class Expr {
const k = this.kind;
switch (k.tag) {
case "Int":
return;
break;
case "Add":
k.left.visit(v);
k.right.visit(v);
return
}
break;
default:
k satisfies never;
}
}
// ...
}
```

View File

@ -157,10 +157,11 @@ class Val {
return `${k.value}`;
case "Fn":
return `<${k.fn.ty.pretty()}>`;
}
default:
k satisfies never;
}
}
}
type ValKind =
| { tag: "Void" }