diff options
author | Nadrieril | 2019-12-27 17:23:21 +0000 |
---|---|---|
committer | Nadrieril | 2020-01-17 10:06:00 +0000 |
commit | 8cbec8c75d9e52091bdfe28b60b6ee698d9c1392 (patch) | |
tree | 2d9c31ee659307b9fed3e275d5a0a6fa282c5101 | |
parent | bc3599b815c6f9cad2f4efd30c009cbe8f765ca1 (diff) |
Store corresponding binder id in AlphaVar
Diffstat (limited to '')
-rw-r--r-- | dhall/src/semantics/core/var.rs | 24 | ||||
-rw-r--r-- | dhall/src/semantics/phase/typecheck.rs | 3 |
2 files changed, 16 insertions, 11 deletions
diff --git a/dhall/src/semantics/core/var.rs b/dhall/src/semantics/core/var.rs index 28ddadd..98b315e 100644 --- a/dhall/src/semantics/core/var.rs +++ b/dhall/src/semantics/core/var.rs @@ -9,6 +9,8 @@ use crate::syntax::{ExprKind, InterpolatedTextContents, Label, V}; pub struct AlphaVar { normal: V<Label>, alpha: V<()>, + /// Id of the corresponding binder. + binder_uid: BinderUID, } type BinderUID = u64; @@ -93,6 +95,7 @@ impl Shift for AlphaVar { Some(AlphaVar { normal: self.normal.shift(delta, &var.normal)?, alpha: self.alpha.shift(delta, &var.alpha)?, + binder_uid: self.binder_uid, }) } } @@ -121,23 +124,24 @@ impl std::fmt::Debug for Binder { } } -impl From<Label> for AlphaVar { - fn from(x: Label) -> AlphaVar { +impl<'a> From<&'a Label> for AlphaVar { + fn from(x: &'a Label) -> AlphaVar { AlphaVar { - normal: V(x, 0), + normal: V(x.clone(), 0), alpha: V((), 0), + // TODO: evil evil but only used in shift + binder_uid: 0, } } } -impl<'a> From<&'a Label> for AlphaVar { - fn from(x: &'a Label) -> AlphaVar { - x.clone().into() - } -} impl From<Binder> for AlphaVar { fn from(x: Binder) -> AlphaVar { - let l: Label = x.into(); - l.into() + let binder_uid = x.uid; + AlphaVar { + normal: V(x.into(), 0), + alpha: V((), 0), + binder_uid, + } } } impl<'a> From<&'a Binder> for AlphaVar { diff --git a/dhall/src/semantics/phase/typecheck.rs b/dhall/src/semantics/phase/typecheck.rs index 926598d..7e408eb 100644 --- a/dhall/src/semantics/phase/typecheck.rs +++ b/dhall/src/semantics/phase/typecheck.rs @@ -494,10 +494,11 @@ fn type_last_layer( ValueKind::UnionType(kts) => match kts.get(&x) { // Constructor has type T -> < x: T, ... > Some(Some(t)) => { + let x = ctx.new_binder(x); RetTypeOnly( tck_pi_type( ctx, - ctx.new_binder(x), + x.clone(), t.clone(), r.under_binder(x), )? |