diff --git a/kiss/src/kiss/SpecialForms.hx b/kiss/src/kiss/SpecialForms.hx index 6e5943b9..87007320 100644 --- a/kiss/src/kiss/SpecialForms.hx +++ b/kiss/src/kiss/SpecialForms.hx @@ -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 ) branch must come last in a (case <...>) expression"); default: diff --git a/kiss/src/test/cases/BasicTestCase.kiss b/kiss/src/test/cases/BasicTestCase.kiss index 23f0fb40..6079e69c 100644 --- a/kiss/src/test/cases/BasicTestCase.kiss +++ b/kiss/src/test/cases/BasicTestCase.kiss @@ -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 [])