diff options
author | Nadrieril | 2020-12-07 14:15:43 +0000 |
---|---|---|
committer | Nadrieril | 2020-12-07 19:34:39 +0000 |
commit | 8c5b3ff15f2125e9d731fc199e194e1993c36b37 (patch) | |
tree | a88ac770aa3e7605feed8381877f290a2b64cd43 /serde_dhall | |
parent | 3c522217b7445c6df9e170d830f485086ad7e062 (diff) |
Thread cx everywhere else imports are read
Diffstat (limited to 'serde_dhall')
-rw-r--r-- | serde_dhall/src/options/de.rs | 1 | ||||
-rw-r--r-- | serde_dhall/src/value.rs | 17 |
2 files changed, 13 insertions, 5 deletions
diff --git a/serde_dhall/src/options/de.rs b/serde_dhall/src/options/de.rs index d57759a..fc8c6dc 100644 --- a/serde_dhall/src/options/de.rs +++ b/serde_dhall/src/options/de.rs @@ -250,6 +250,7 @@ impl<'a, A> Deserializer<'a, A> { Some(ty) => resolved.typecheck_with(cx, &ty.to_hir())?, }; Ok(Value::from_nir_and_ty( + cx, typed.normalize(cx).as_nir(), typed.ty().as_nir(), )) diff --git a/serde_dhall/src/value.rs b/serde_dhall/src/value.rs index e5f5acd..b259c4b 100644 --- a/serde_dhall/src/value.rs +++ b/serde_dhall/src/value.rs @@ -5,6 +5,7 @@ use dhall::operations::OpKind; use dhall::semantics::{Hir, HirKind, Nir, NirKind}; pub use dhall::syntax::NumKind; use dhall::syntax::{Expr, ExprKind, Span}; +use dhall::Ctxt; use crate::{Error, ErrorKind, FromDhall, Result, ToDhall}; @@ -206,7 +207,11 @@ pub enum SimpleType { } impl Value { - pub(crate) fn from_nir_and_ty(x: &Nir, ty: &Nir) -> Result<Self> { + pub(crate) fn from_nir_and_ty<'cx>( + cx: Ctxt<'cx>, + x: &Nir<'cx>, + ty: &Nir<'cx>, + ) -> Result<Self> { Ok(if let Some(val) = SimpleValue::from_nir(x) { // The type must be simple if the value is simple. let ty = SimpleType::from_nir(ty).unwrap(); @@ -218,7 +223,7 @@ impl Value { kind: ValueKind::Ty(ty), } } else { - let expr = x.to_hir_noenv().to_expr(Default::default()); + let expr = x.to_hir_noenv().to_expr(cx, Default::default()); return Err(Error(ErrorKind::Deserialize(format!( "this is neither a simple type nor a simple value: {}", expr @@ -342,7 +347,7 @@ impl SimpleValue { let type_error = || { Error(ErrorKind::Serialize(format!( "expected a value of type {}, found {:?}", - ty.unwrap().to_hir().to_expr(Default::default()), + ty.unwrap().to_expr(), self ))) }; @@ -439,7 +444,9 @@ impl SimpleValue { /// Converts back to the corresponding AST expression. pub(crate) fn to_expr(&self, ty: Option<&SimpleType>) -> Result<Expr> { - Ok(self.to_hir(ty)?.to_expr(Default::default())) + Ctxt::with_new(|cx| { + Ok(self.to_hir(ty)?.to_expr(cx, Default::default())) + }) } } @@ -514,7 +521,7 @@ impl SimpleType { /// Converts back to the corresponding AST expression. pub(crate) fn to_expr(&self) -> Expr { - self.to_hir().to_expr(Default::default()) + Ctxt::with_new(|cx| self.to_hir().to_expr(cx, Default::default())) } } |