feat: register import, types, and values in environment

This commit is contained in:
rvcas
2022-10-18 19:55:46 -04:00
committed by Lucas
parent d0287d418b
commit 81c87ab4da
11 changed files with 1773 additions and 38 deletions

View File

@@ -45,6 +45,15 @@ pub enum Error {
},
}
impl Error {
pub fn total(&self) -> usize {
match self {
Error::List(errors) => errors.len(),
_ => 1,
}
}
}
impl Debug for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let miette_handler = MietteHandlerOpts::new()

View File

@@ -49,15 +49,23 @@ fn main() -> miette::Result<()> {
let mut project = Project::new(config, project_path);
if let Err(err) = project.build() {
match err {
let build_result = project.build();
for warning in project.warnings {
eprintln!("Warning: {:?}", warning)
}
if let Err(err) = build_result {
match &err {
error::Error::List(errors) => {
for error in errors {
eprintln!("Error: {:?}", error)
}
}
rest => Err(rest)?,
rest => eprintln!("Error: {:?}", rest),
}
miette::bail!("failed: {} errors", err.total());
};
}

View File

@@ -42,7 +42,7 @@ pub struct Project {
module_types: HashMap<String, tipo::Module>,
root: PathBuf,
sources: Vec<Source>,
warnings: Vec<Warning>,
pub warnings: Vec<Warning>,
}
impl Project {