summaryrefslogtreecommitdiff
path: root/dhall/src/semantics/resolve/hir.rs
diff options
context:
space:
mode:
authorNadrieril2020-12-07 14:32:06 +0000
committerNadrieril2020-12-07 19:34:39 +0000
commitc1fe26d45c831eec015ad5c015236fce1928613a (patch)
treebdba83d6854005d4de29fc38427967989367da6f /dhall/src/semantics/resolve/hir.rs
parent8c5b3ff15f2125e9d731fc199e194e1993c36b37 (diff)
Pass import results via the global context
Diffstat (limited to 'dhall/src/semantics/resolve/hir.rs')
-rw-r--r--dhall/src/semantics/resolve/hir.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/dhall/src/semantics/resolve/hir.rs b/dhall/src/semantics/resolve/hir.rs
index 5575888..cfde47e 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::semantics::{type_with, NameEnv, Nir, NzEnv, Tir, TyEnv};
use crate::syntax::{Expr, ExprKind, Span, V};
-use crate::{Ctxt, ToExprOptions};
+use crate::{Ctxt, ImportId, ToExprOptions};
/// Stores an alpha-normalized variable.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@@ -13,8 +13,8 @@ pub struct AlphaVar {
pub enum HirKind<'cx> {
/// A resolved variable (i.e. a DeBruijn index)
Var(AlphaVar),
- /// Result of resolving an import.
- Import(Hir<'cx>, Type<'cx>),
+ /// An import. It must have been resolved by the time we get to typechecking/normalization.
+ Import(ImportId<'cx>),
// Forbidden ExprKind variants: Var, Import, Completion
Expr(ExprKind<Hir<'cx>>),
}
@@ -104,8 +104,9 @@ fn hir_to_expr<'cx>(
let kind = match hir.kind() {
HirKind::Var(v) if opts.alpha => ExprKind::Var(V("_".into(), v.idx())),
HirKind::Var(v) => ExprKind::Var(env.label_var(*v)),
- HirKind::Import(hir, _) => {
- return hir_to_expr(cx, hir, opts, &mut NameEnv::new());
+ HirKind::Import(import) => {
+ let typed = cx[import].unwrap_result();
+ return hir_to_expr(cx, &typed.hir, opts, &mut NameEnv::new());
}
HirKind::Expr(e) => {
let e = e.map_ref_maybe_binder(|l, hir| {