it runs! gets the wrong answer, but runs!

This commit is contained in:
2024-02-17 09:38:12 -08:00
parent 9d41cf0da7
commit 7edaf747aa
8 changed files with 491 additions and 26 deletions

View File

@@ -13,6 +13,7 @@ use std::str::FromStr;
/// that we're not going to be able to work through. As with most
/// of these errors, we recommend converting this to a [`Diagnostic`]
/// and using [`codespan_reporting`] to present them to the user.
#[derive(Debug)]
pub enum Error {
UnboundVariable(Location, String),
UnknownType(Location, String),
@@ -83,6 +84,9 @@ impl Program {
let mut warnings = vec![];
for stmt in self.items.iter() {
if let TopLevel::Function(Some(name), _, _) = stmt {
bound_variables.insert(name.to_string(), name.location.clone());
}
let (mut new_errors, mut new_warnings) = stmt.validate_with_bindings(bound_variables);
errors.append(&mut new_errors);
warnings.append(&mut new_warnings);