diff options
author | Nadrieril | 2019-03-16 22:41:22 +0100 |
---|---|---|
committer | Nadrieril | 2019-03-16 22:41:22 +0100 |
commit | 0f33caf4c1ee4d1f95d6ac3a41b5cf2f8efa7b54 (patch) | |
tree | 36607a1eb1eaf327388d2026d192782cdb6d130d /dhall/src/typecheck.rs | |
parent | 5692bf2c8a7acfb90a5d03d0bd360c105ba2a72b (diff) |
Use Box more uniformly in AST
Closes #28
Diffstat (limited to 'dhall/src/typecheck.rs')
-rw-r--r-- | dhall/src/typecheck.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/dhall/src/typecheck.rs b/dhall/src/typecheck.rs index 0f87d67..ca0d5af 100644 --- a/dhall/src/typecheck.rs +++ b/dhall/src/typecheck.rs @@ -270,7 +270,7 @@ where Err(TypeError::new( ctx, e, - TypeMismatch((**f).clone(), nf_A, (*a).clone(), nf_A2), + TypeMismatch((**f).clone(), nf_A, (**a).clone(), nf_A2), )) } } @@ -436,7 +436,7 @@ where return Err(TypeError::new( ctx, e, - InvalidListElement(i, nf_t, x.clone(), nf_t2), + InvalidListElement(i, nf_t, (**x).clone(), nf_t2), )); } } @@ -529,7 +529,7 @@ where return Err(TypeError::new( ctx, e, - InvalidFieldType((*k).clone(), (*t).clone()), + InvalidFieldType((*k).clone(), (**t).clone()), )); } } @@ -548,11 +548,11 @@ where return Err(TypeError::new( ctx, e, - InvalidField((*k).clone(), (*v).clone()), + InvalidField((*k).clone(), (**v).clone()), )); } } - Ok(((*k).clone(), t)) + Ok(((*k).clone(), bx(t))) }) .collect::<Result<_, _>>()?; Ok(Record(kts)) @@ -641,13 +641,15 @@ where Field(ref r, ref x) => { let t = normalize(&type_with(ctx, r)?); match t { - Record(ref kts) => kts.get(x).cloned().ok_or_else(|| { - TypeError::new( - ctx, - e, - MissingField((*x).clone(), t.clone()), - ) - }), + Record(ref kts) => { + kts.get(x).map(|x| &**x).cloned().ok_or_else(|| { + TypeError::new( + ctx, + e, + MissingField((*x).clone(), t.clone()), + ) + }) + } _ => Err(TypeError::new( ctx, e, |