Implement static name resolution (#958)

This doesn't actually use the results of name resolution, but it does verify that they are present.
Also ensures that name resolution and type checking are applied to deduced function parameters and the implicit call to `Main()`.

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
This commit is contained in:
Geoff RomerandJon Meow authored and GitHub committed 2021-11-30 13:33:54 -08:00
1 parent dc5e62fc7a
commit 17e0a1afb9
12 files changed
+347 -22

No files matched your search

@@ -302,6 +302,9 @@ void Interpreter::StepLvalue() {
case ExpressionKind::IdentifierExpression: {
// { {x :: C, E, F} :: S, H}
// -> { {E(x) :: C, E, F} :: S, H}
CHECK(cast<IdentifierExpression>(exp).has_named_entity())
<< "Identifier '" << exp << "' at " << exp.source_loc()
<< " was not resolved";
Address pointer =
GetFromEnv(exp.source_loc(), cast<IdentifierExpression>(exp).name());
Nonnull<const Value*> v = arena_->New<LValue>(pointer);
@@ -512,6 +515,9 @@ void Interpreter::StepExp() {
case ExpressionKind::IdentifierExpression: {
CHECK(act.pos() == 0);
const auto& ident = cast<IdentifierExpression>(exp);
CHECK(ident.has_named_entity())
<< "Identifier '" << exp << "' at " << exp.source_loc()
<< " was not resolved";
// { {x :: C, E, F} :: S, H} -> { {H(E(x)) :: C, E, F} :: S, H}
Address pointer = GetFromEnv(exp.source_loc(), ident.name());
return todo_.FinishAction(heap_.Read(pointer, exp.source_loc()));