From ba19f41873fec98bb24ba709f4b76c3f58ca5aaa Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 15 Aug 2019 13:05:23 +0200 Subject: Fix bug in shifting contexts --- dhall/src/core/context.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'dhall/src/core/context.rs') diff --git a/dhall/src/core/context.rs b/dhall/src/core/context.rs index 62affcf..8d14415 100644 --- a/dhall/src/core/context.rs +++ b/dhall/src/core/context.rs @@ -97,7 +97,16 @@ impl Context { where T: Clone + Shift, { - Some(self.do_with_var(var, |var, i| Ok(i.shift(delta, &var)?))?) + if delta < 0 { + Some(self.do_with_var(var, |var, i| Ok(i.shift(delta, &var)?))?) + } else { + Some(Context(Rc::new( + self.0 + .iter() + .map(|(l, i)| Ok((l.clone(), i.shift(delta, &var)?))) + .collect::>()?, + ))) + } } fn subst_shift(&self, var: &AlphaVar, val: &Typed) -> Self where -- cgit v1.2.3 From 88ebc0f9d561a2541aad84a3152511a0439db8b4 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 16 Aug 2019 17:56:19 +0200 Subject: Reduce api surface of dhall crate Helps detect unused code --- dhall/src/core/context.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'dhall/src/core/context.rs') diff --git a/dhall/src/core/context.rs b/dhall/src/core/context.rs index 8d14415..9230a2e 100644 --- a/dhall/src/core/context.rs +++ b/dhall/src/core/context.rs @@ -10,19 +10,19 @@ use crate::error::TypeError; use crate::phase::{Type, Typed}; #[derive(Debug, Clone)] -pub enum CtxItem { +enum CtxItem { Kept(AlphaVar, T), Replaced(Thunk, T), } #[derive(Debug, Clone)] -pub struct Context(Rc)>>); +struct Context(Rc)>>); #[derive(Debug, Clone)] -pub struct NormalizationContext(Context<()>); +pub(crate) struct NormalizationContext(Context<()>); #[derive(Debug, Clone)] -pub struct TypecheckContext(Context); +pub(crate) struct TypecheckContext(Context); impl Context { pub fn new() -> Self { -- cgit v1.2.3 From 5f0d69671b44ba1dff6becb9ebc7f6e74241e3e2 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 16 Aug 2019 18:14:55 +0200 Subject: Remove dead code --- dhall/src/core/context.rs | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'dhall/src/core/context.rs') diff --git a/dhall/src/core/context.rs b/dhall/src/core/context.rs index 9230a2e..3c07c1c 100644 --- a/dhall/src/core/context.rs +++ b/dhall/src/core/context.rs @@ -18,9 +18,6 @@ enum CtxItem { #[derive(Debug, Clone)] struct Context(Rc)>>); -#[derive(Debug, Clone)] -pub(crate) struct NormalizationContext(Context<()>); - #[derive(Debug, Clone)] pub(crate) struct TypecheckContext(Context); @@ -117,22 +114,6 @@ impl Context { } } -impl NormalizationContext { - pub fn new() -> Self { - NormalizationContext(Context::new()) - } - pub fn skip(&self, x: &Label) -> Self { - NormalizationContext(self.0.insert_kept(x, ())) - } - pub fn lookup(&self, var: &V