From 6792d3da32d11b5303b00d1cc667f6f946d8bf33 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 4 May 2019 19:51:26 +0200 Subject: We actually don't need SubExpr::shift anymore --- dhall/src/normalize.rs | 9 +++--- dhall_syntax/src/core.rs | 81 ------------------------------------------------ 2 files changed, 5 insertions(+), 85 deletions(-) diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs index 8ae746d..d84c2d5 100644 --- a/dhall/src/normalize.rs +++ b/dhall/src/normalize.rs @@ -187,17 +187,18 @@ impl Value { let a = n.normalize_to_expr(); dhall::subexpr!(λ(x: a) -> Some x) } - Value::ListConsClosure(n, None) => { - let a = n.normalize_to_expr(); + Value::ListConsClosure(a, None) => { // Avoid accidental capture of the new `x` variable let a1 = a.shift(1, &Label::from("x").into()); + let a1 = a1.normalize_to_expr(); + let a = a.normalize_to_expr(); dhall::subexpr!(λ(x : a) -> λ(xs : List a1) -> [ x ] # xs) } Value::ListConsClosure(n, Some(v)) => { - let v = v.normalize_to_expr(); - let a = n.normalize_to_expr(); // Avoid accidental capture of the new `xs` variable let v = v.shift(1, &Label::from("xs").into()); + let v = v.normalize_to_expr(); + let a = n.normalize_to_expr(); dhall::subexpr!(λ(xs : List a) -> [ v ] # xs) } Value::NaturalSuccClosure => { diff --git a/dhall_syntax/src/core.rs b/dhall_syntax/src/core.rs index a186d19..7cdda64 100644 --- a/dhall_syntax/src/core.rs +++ b/dhall_syntax/src/core.rs @@ -1,9 +1,7 @@ #![allow(non_snake_case)] use std::collections::BTreeMap; -use std::collections::HashMap; use std::rc::Rc; -use crate::context::Context; use crate::visitor; use crate::*; @@ -436,36 +434,6 @@ impl SubExpr { )), } } - - /// `shift` is used by both normalization and type-checking to avoid variable - /// capture by shifting variable indices - /// See https://github.com/dhall-lang/dhall-lang/blob/master/standard/semantics.md#shift - /// for details - pub fn shift(&self, delta: isize, var: &V