catch a (never otherwise) bug I hadn't thought of
This commit is contained in:
@@ -344,6 +344,11 @@ class SpecialForms {
|
||||
cases[i] = b.call(neverExps[0], [
|
||||
b.callSymbol('throw', [
|
||||
b.callSymbol('kiss.Prelude.runtimeInsertAssertionMessage', [b.str('${Reader.toString(neverExps[0].def)} should never match pattern ${Reader.toString(neverExps[0].def)}'), b.str(failureError), b.int(colonsInPrefix)])])]);
|
||||
default:
|
||||
}
|
||||
}
|
||||
for (i in 0...cases.length) {
|
||||
switch (cases[i].def) {
|
||||
case CallExp({pos: _, def: Symbol("otherwise")}, _) if (i != cases.length - 1):
|
||||
throw KissError.fromExp(cases[i], "(otherwise <body...>) branch must come last in a (case <...>) expression");
|
||||
default:
|
||||
|
@@ -363,6 +363,8 @@ From:[(assert false (+ \"false \" \"should \" \"have \" \"been \" \"true\"))]" m
|
||||
(function _testCase []
|
||||
// otherwise branch must come last
|
||||
(assertThrowsAtCompileTime (case null (otherwise "thing") (v "OtherThing")))
|
||||
// Even if it is in (never otherwise) form
|
||||
(assertThrowsAtCompileTime (case null (never otherwise) (v "OtherThing")))
|
||||
// null must be matched
|
||||
(assertThrowsAtCompileTime (case null (v "thing")))
|
||||
(case (toOption [])
|
||||
|
Reference in New Issue
Block a user