summaryrefslogtreecommitdiff
path: root/dhall/src/semantics/resolve
diff options
context:
space:
mode:
authorNadrieril2020-12-06 21:41:03 +0000
committerNadrieril2020-12-07 19:34:38 +0000
commit6287b7a7f9e421877ee13fefa586395fec844c99 (patch)
tree65129001dbd7e56561df656dc8eee8f441a05b25 /dhall/src/semantics/resolve
parent9991bd4891774c4dd598decae02ee860554d2ab7 (diff)
Thread cx through typecheck
Diffstat (limited to 'dhall/src/semantics/resolve')
-rw-r--r--dhall/src/semantics/resolve/hir.rs9
-rw-r--r--dhall/src/semantics/resolve/resolve.rs6
2 files changed, 9 insertions, 6 deletions
diff --git a/dhall/src/semantics/resolve/hir.rs b/dhall/src/semantics/resolve/hir.rs
index 8869915..c2d1883 100644
--- a/dhall/src/semantics/resolve/hir.rs
+++ b/dhall/src/semantics/resolve/hir.rs
@@ -1,7 +1,7 @@
use crate::error::TypeError;
use crate::semantics::{type_with, NameEnv, Nir, NzEnv, Tir, TyEnv, Type};
use crate::syntax::{Expr, ExprKind, Span, V};
-use crate::ToExprOptions;
+use crate::{Ctxt, ToExprOptions};
/// Stores an alpha-normalized variable.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@@ -76,8 +76,11 @@ impl Hir {
) -> Result<Tir<'hir>, TypeError> {
type_with(env, self, None)
}
- pub fn typecheck_noenv<'hir>(&'hir self) -> Result<Tir<'hir>, TypeError> {
- self.typecheck(&TyEnv::new())
+ pub fn typecheck_noenv<'hir>(
+ &'hir self,
+ cx: Ctxt<'_>,
+ ) -> Result<Tir<'hir>, TypeError> {
+ self.typecheck(&TyEnv::new(cx))
}
/// Eval the Hir. It will actually get evaluated only as needed on demand.
diff --git a/dhall/src/semantics/resolve/resolve.rs b/dhall/src/semantics/resolve/resolve.rs
index 955e2fa..cf72f80 100644
--- a/dhall/src/semantics/resolve/resolve.rs
+++ b/dhall/src/semantics/resolve/resolve.rs
@@ -250,7 +250,7 @@ impl ImportLocation {
ImportMode::Location => {
let expr = self.kind.to_location();
let hir = skip_resolve_expr(&expr)?;
- let ty = hir.typecheck_noenv()?.ty().clone();
+ let ty = hir.typecheck_noenv(env.cx())?.ty().clone();
(hir, ty)
}
};
@@ -463,8 +463,8 @@ fn resolve_with_env<'cx>(
Ok(Resolved(resolved))
}
-pub fn resolve(parsed: Parsed) -> Result<Resolved, Error> {
- Ctxt::with_new(|cx| resolve_with_env(&mut ImportEnv::new(cx), parsed))
+pub fn resolve(cx: Ctxt<'_>, parsed: Parsed) -> Result<Resolved, Error> {
+ resolve_with_env(&mut ImportEnv::new(cx), parsed)
}
pub fn skip_resolve_expr(expr: &Expr) -> Result<Hir, Error> {