summaryrefslogtreecommitdiff
path: root/dhall/src/semantics/tck
diff options
context:
space:
mode:
authorNadrieril2020-06-25 16:47:59 +0100
committerGitHub2020-06-25 16:47:59 +0100
commitb63e00cebff4a8b53c23faac2881fae640da7db2 (patch)
tree36a8786cb158c676ebb32bbb8255a93297d07091 /dhall/src/semantics/tck
parent4c80de149200a86f7fc13c725160dafb35d0ac08 (diff)
parentb9c7bf6744fcbf30b988a50fd0b8c28e23f22d29 (diff)
Merge pull request #171 from Nadrieril/catchup-spec
Diffstat (limited to 'dhall/src/semantics/tck')
-rw-r--r--dhall/src/semantics/tck/typecheck.rs20
1 files changed, 5 insertions, 15 deletions
diff --git a/dhall/src/semantics/tck/typecheck.rs b/dhall/src/semantics/tck/typecheck.rs
index 361e1b4..d21c7ce 100644
--- a/dhall/src/semantics/tck/typecheck.rs
+++ b/dhall/src/semantics/tck/typecheck.rs
@@ -137,30 +137,20 @@ fn type_one_layer(
Type::from_const(k)
}
ExprKind::UnionType(kts) => {
- // Check that all types are the same const
- let mut k = None;
+ // An empty union type has type Type;
+ // an union type with only unary variants also has type Type
+ let mut k = Const::Type;
for t in kts.values() {
if let Some(t) = t {
- let c = match t.ty().as_const() {
- Some(c) => c,
+ match t.ty().as_const() {
+ Some(c) => k = max(k, c),
None => {
return mk_span_err(t.span(), "InvalidVariantType")
}
- };
- match k {
- None => k = Some(c),
- Some(k) if k == c => {}
- _ => {
- return mk_span_err(t.span(), "InvalidVariantType")
- }
}
}
}
- // An empty union type has type Type;
- // an union type with only unary variants also has type Type
- let k = k.unwrap_or(Const::Type);
-
Type::from_const(k)
}
ExprKind::Op(op) => typecheck_operation(env, span, op)?,