diff options
author | Nadrieril | 2019-04-13 22:17:17 +0200 |
---|---|---|
committer | Nadrieril | 2019-04-13 22:17:17 +0200 |
commit | bc972ab7f76afa5bffcfbf705a2ecc30473fc4a2 (patch) | |
tree | 499d5acdc0610eb2550ebb5afa8e3a012ac98327 /dhall | |
parent | 427a3416507db3fd4b534322d996bc8aafba5259 (diff) |
Implement ListAppend typechecking
Diffstat (limited to '')
-rw-r--r-- | dhall/src/typecheck.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/dhall/src/typecheck.rs b/dhall/src/typecheck.rs index d241d8d..8ca48eb 100644 --- a/dhall/src/typecheck.rs +++ b/dhall/src/typecheck.rs @@ -622,6 +622,23 @@ fn type_last_layer( DoubleLit(_) => Ok(RetType(simple_type_from_builtin(Double))), // TODO: check type of interpolations TextLit(_) => Ok(RetType(simple_type_from_builtin(Text))), + BinOp(o@ListAppend, l, r) => { + match l.get_type()?.as_normalized()?.as_expr().as_ref() { + App(f, args) if args.len() == 1 => match f.as_ref() { + Builtin(List) => {} + _ => return Err(mkerr(BinOpTypeMismatch(o, l))), + } + _ => return Err(mkerr(BinOpTypeMismatch(o, l))), + } + + ensure_equal!( + l.get_type()?, + r.get_type()?, + mkerr(BinOpTypeMismatch(o, r)) + ); + + Ok(RetType(l.get_type()?.into_owned())) + } BinOp(o, l, r) => { let t = simple_type_from_builtin(match o { BoolAnd => Bool, @@ -631,6 +648,7 @@ fn type_last_layer( NaturalPlus => Natural, NaturalTimes => Natural, TextAppend => Text, + ListAppend => unreachable!(), _ => return Err(mkerr(Unimplemented)), }); @@ -986,8 +1004,8 @@ mod spec_tests { ti_success!(ti_success_unit_OperatorAndNormalizeArguments, "unit/OperatorAndNormalizeArguments"); ti_success!(ti_success_unit_OperatorEqual, "unit/OperatorEqual"); ti_success!(ti_success_unit_OperatorEqualNormalizeArguments, "unit/OperatorEqualNormalizeArguments"); - // ti_success!(ti_success_unit_OperatorListConcatenate, "unit/OperatorListConcatenate"); - // ti_success!(ti_success_unit_OperatorListConcatenateNormalizeArguments, "unit/OperatorListConcatenateNormalizeArguments"); + ti_success!(ti_success_unit_OperatorListConcatenate, "unit/OperatorListConcatenate"); + ti_success!(ti_success_unit_OperatorListConcatenateNormalizeArguments, "unit/OperatorListConcatenateNormalizeArguments"); ti_success!(ti_success_unit_OperatorNotEqual, "unit/OperatorNotEqual"); ti_success!(ti_success_unit_OperatorNotEqualNormalizeArguments, "unit/OperatorNotEqualNormalizeArguments"); ti_success!(ti_success_unit_OperatorOr, "unit/OperatorOr"); |