From 8bc33c16e90ff6e1d2b4ddc7317a91190c9d8540 Mon Sep 17 00:00:00 2001 From: FintanH Date: Sat, 3 Aug 2019 18:54:01 +0100 Subject: Simplify Const checking logic --- dhall/src/phase/typecheck.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'dhall/src') diff --git a/dhall/src/phase/typecheck.rs b/dhall/src/phase/typecheck.rs index 3bff7ca..75f78ac 100644 --- a/dhall/src/phase/typecheck.rs +++ b/dhall/src/phase/typecheck.rs @@ -687,17 +687,13 @@ fn type_last_layer( }; // Const values must match for the Records - let k = match (k_l, k_r) { - (dhall_syntax::Const::Type, dhall_syntax::Const::Type) => dhall_syntax::Const::Type, - (dhall_syntax::Const::Kind, dhall_syntax::Const::Kind) => dhall_syntax::Const::Kind, - (dhall_syntax::Const::Sort, dhall_syntax::Const::Sort) => dhall_syntax::Const::Sort, - (l_mismatch, r_mismatch) => - return Err(mkerr(RecordTypeMismatch( - Typed::from_const(l_mismatch), - Typed::from_const(r_mismatch), - l.clone(), - r.clone(), - ))), + let k = if k_l == k_r { k_l } else { + return Err(mkerr(RecordTypeMismatch( + Typed::from_const(k_l), + Typed::from_const(k_r), + l.clone(), + r.clone(), + ))) }; // Extract the LHS record type -- cgit v1.2.3