From c1fe26d45c831eec015ad5c015236fce1928613a Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 7 Dec 2020 14:32:06 +0000 Subject: Pass import results via the global context --- dhall/src/semantics/resolve/hir.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'dhall/src/semantics/resolve/hir.rs') 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>), } @@ -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| { -- cgit v1.2.3