summaryrefslogtreecommitdiff
path: root/dhall/src/semantics/resolve
diff options
context:
space:
mode:
Diffstat (limited to 'dhall/src/semantics/resolve')
-rw-r--r--dhall/src/semantics/resolve/hir.rs13
-rw-r--r--dhall/src/semantics/resolve/resolve.rs9
2 files changed, 11 insertions, 11 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| {
diff --git a/dhall/src/semantics/resolve/resolve.rs b/dhall/src/semantics/resolve/resolve.rs
index db162ef..011ed45 100644
--- a/dhall/src/semantics/resolve/resolve.rs
+++ b/dhall/src/semantics/resolve/resolve.rs
@@ -348,7 +348,7 @@ fn desugar(expr: &Expr) -> Cow<'_, Expr> {
fn traverse_resolve_expr<'cx>(
name_env: &mut NameEnv,
expr: &Expr,
- f: &mut impl FnMut(Import, Span) -> Result<Typed<'cx>, Error>,
+ f: &mut impl FnMut(Import, Span) -> Result<ImportId<'cx>, Error>,
) -> Result<Hir<'cx>, Error> {
let expr = desugar(expr);
Ok(match expr.kind() {
@@ -387,8 +387,8 @@ fn traverse_resolve_expr<'cx>(
ExprKind::Import(import) => {
// TODO: evaluate import headers
let import = import.traverse_ref(|_| Ok::<_, Error>(()))?;
- let imported = f(import, expr.span())?;
- HirKind::Import(imported.hir, imported.ty)
+ let import_id = f(import, expr.span())?;
+ HirKind::Import(import_id)
}
kind => HirKind::Expr(kind),
};
@@ -463,8 +463,7 @@ fn resolve_with_env<'cx>(
let import_id =
env.cx().push_import(base_location.clone(), import, span);
fetch_import(env, import_id)?;
- // TODO: store import id in Hir
- Ok(env.cx()[import_id].unwrap_result().clone())
+ Ok(import_id)
},
)?;
Ok(Resolved(resolved))