pub fn resolve<L: Lookup>(
hir: Hir,
names: &L,
) -> Result<Resolution, ResolveError>Expand description
Resolves one unit with the default (lexical, Kraken-style) policy and no environment: the lazy path.
names is the interner the unit’s names were interned in; it is read
only to compare spellings for did-you-mean suggestions.
§Errors
ResolveError::BudgetExceeded if the unit exceeds the default
Budget. Name errors in the program are diagnostics in the result, not
errors.
§Examples
use hir_lang::{Builder, Name};
use intern_lang::Interner;
let mut names = Interner::new();
let mut b = Builder::new();
let lenght = b.name_expr(Name::new(names.intern("lenght")));
let body = b.block(&[], Some(lenght));
let length = b.func(Name::new(names.intern("length")), &[], body);
let root = b.module(None, &[length]);
let res = resolve_lang::resolve(b.finish(root)?, &names)?;
let d = &res.diagnostics()[0];
assert_eq!(d.message(&names), "cannot find value `lenght` in this scope; did you mean `length`?");