From 9e38d92bf481da8e34081c81c813acd802efa016 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 15 Aug 2019 22:03:41 +0200 Subject: Fix variable substitution I have no idea how this didn't get caught before --- dhall/src/core/value.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'dhall/src') diff --git a/dhall/src/core/value.rs b/dhall/src/core/value.rs index 036a20c..75ef5a5 100644 --- a/dhall/src/core/value.rs +++ b/dhall/src/core/value.rs @@ -436,10 +436,8 @@ impl Subst for Value { t.subst_shift(var, val), e.subst_shift(&var.under_binder(x), &val.under_binder(x)), ), - Value::Var(v) => match v.shift(-1, var) { - None => val.to_value().clone(), - Some(newvar) => Value::Var(newvar), - }, + Value::Var(v) if v == var => val.to_value(), + Value::Var(v) => Value::Var(v.shift(-1, var).unwrap()), Value::Const(c) => Value::Const(*c), Value::BoolLit(b) => Value::BoolLit(*b), Value::NaturalLit(n) => Value::NaturalLit(*n), -- cgit v1.2.3