summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadrieril2019-11-11 13:36:30 +0000
committerNadrieril2019-11-11 13:50:37 +0000
commitd28d114552e6c6cb913dce48893fa87e87bf11e2 (patch)
tree94965fc87a814de636705944b5a6f143855235b4
parent575adf9a7a87ba5d75548f7cd4efdec53c1fe17c (diff)
Propagate more spans
Diffstat (limited to '')
-rw-r--r--dhall/src/core/value.rs8
-rw-r--r--dhall/src/phase/typecheck.rs6
-rw-r--r--dhall_syntax/src/core/span.rs3
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<Const> {
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 {