summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadrieril2019-08-15 13:05:23 +0200
committerNadrieril2019-08-15 13:05:23 +0200
commitba19f41873fec98bb24ba709f4b76c3f58ca5aaa (patch)
treeabb991e6048172982036f6556c920f04bdad513b
parent67cdda53d95057174b86878f22dbc0efc0255fd9 (diff)
Fix bug in shifting contexts
-rw-r--r--dhall/src/core/context.rs11
1 files changed, 10 insertions, 1 deletions
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<T> Context<T> {
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::<Result<_, _>>()?,
+ )))
+ }
}
fn subst_shift(&self, var: &AlphaVar, val: &Typed) -> Self
where