From a24f2d1367b2848779014c7bb3ecfe6bfbcff7d7 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 24 Jan 2020 18:38:30 +0000 Subject: Fix some variable shifting failures --- dhall/src/semantics/nze/nzexpr.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'dhall/src/semantics/nze') diff --git a/dhall/src/semantics/nze/nzexpr.rs b/dhall/src/semantics/nze/nzexpr.rs index 723c895..49aa704 100644 --- a/dhall/src/semantics/nze/nzexpr.rs +++ b/dhall/src/semantics/nze/nzexpr.rs @@ -217,6 +217,9 @@ impl QuoteEnv { pub fn new() -> Self { QuoteEnv { size: 0 } } + pub fn construct(size: usize) -> Self { + QuoteEnv { size } + } pub fn insert(&self) -> Self { QuoteEnv { size: self.size + 1, @@ -231,6 +234,11 @@ impl NzVar { pub fn new(idx: usize) -> Self { NzVar { idx } } + pub fn shift(&self, delta: isize) -> Self { + NzVar { + idx: (self.idx as isize + delta) as usize, + } + } } impl TyExpr { -- cgit v1.2.3