From d28d114552e6c6cb913dce48893fa87e87bf11e2 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 11 Nov 2019 13:36:30 +0000 Subject: Propagate more spans --- dhall/src/core/value.rs | 8 ++++++-- dhall/src/phase/typecheck.rs | 6 +++--- dhall_syntax/src/core/span.rs | 3 --- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/dhall/src/core/value.rs b/dhall/src/core/value.rs index b6c156e..61c7015 100644 --- a/dhall/src/core/value.rs +++ b/dhall/src/core/value.rs @@ -136,7 +136,7 @@ impl Value { .into_value() } pub(crate) fn from_valuef_and_type(v: ValueF, t: Value) -> Value { - Value::new(v, Unevaled, t, Span::PlaceHolder) + Value::new(v, Unevaled, t, Span::Artificial) } pub(crate) fn from_valuef_and_type_and_span( v: ValueF, @@ -146,7 +146,7 @@ impl Value { Value::new(v, Unevaled, t, span) } pub(crate) fn from_valuef_and_type_whnf(v: ValueF, t: Value) -> Value { - Value::new(v, WHNF, t, Span::PlaceHolder) + Value::new(v, WHNF, t, Span::Artificial) } pub(crate) fn from_const(c: Const) -> Self { const_to_value(c) @@ -154,6 +154,10 @@ impl Value { pub(crate) fn from_builtin(b: Builtin) -> Self { builtin_to_value(b) } + pub(crate) fn with_span(self, span: Span) -> Self { + self.as_internal_mut().span = span; + self + } pub(crate) fn as_const(&self) -> Option { match &*self.as_whnf() { diff --git a/dhall/src/phase/typecheck.rs b/dhall/src/phase/typecheck.rs index 9d2c69b..33919e4 100644 --- a/dhall/src/phase/typecheck.rs +++ b/dhall/src/phase/typecheck.rs @@ -586,7 +586,7 @@ fn type_last_layer( l.get_type()?, r.get_type()?, ), - Span::PlaceHolder, + Span::Artificial, )?), BinOp(RecursiveRecordTypeMerge, l, r) => { use crate::phase::normalize::merge_maps; @@ -622,7 +622,7 @@ fn type_last_layer( l.clone(), r.clone(), ), - Span::PlaceHolder, + Span::Artificial, ) }, )?; @@ -795,7 +795,7 @@ fn type_last_layer( typ, span, ), - RetWhole(v) => v, + RetWhole(v) => v.with_span(span), }) } diff --git a/dhall_syntax/src/core/span.rs b/dhall_syntax/src/core/span.rs index e2bf26d..d10a53d 100644 --- a/dhall_syntax/src/core/span.rs +++ b/dhall_syntax/src/core/span.rs @@ -22,9 +22,6 @@ pub enum Span { Decoded, /// For expressions constructed during normalization/typecheck Artificial, - /// For when there should be a span but it's not done yet - /// TODO: properly handle spans - PlaceHolder, } impl Span { -- cgit v1.2.3