fix failure to handle otherwise blocks with multiple expressions

This commit is contained in:
2021-10-13 11:30:34 -06:00
parent bdc23b1eca
commit c171c172c3
2 changed files with 9 additions and 3 deletions

View File

@@ -273,10 +273,11 @@ class SpecialForms {
// Therefore only one case is required in a case statement, because one case could be enough
// to cover all patterns.
wholeExp.checkNumArgs(2, null, '(case [expression] [cases...] [optional: (otherwise [default])])');
var b = wholeExp.expBuilder();
var defaultExpr = switch (args[-1].def) {
case CallExp({pos: _, def: Symbol("otherwise")}, [otherwiseExp]):
case CallExp({pos: _, def: Symbol("otherwise")}, otherwiseExps):
args.pop();
k.convert(otherwiseExp);
k.convert(b.begin(otherwiseExps));
default:
null;
};

View File

@@ -378,7 +378,12 @@
((Some (as inner (Some v)))
(Assert.equals 5 v)
(Assert.isTrue (Type.enumEq (Some 5) inner)))
(otherwise (Assert.fail))))
(otherwise (Assert.fail)))
// Otherwise blocks should allow multiple expressions, too:
(case 5
(otherwise
6 5)))
(function _testMaps []
(localVar :Map<String,String> myMap [=>"hey" "you"