Skip to content

Commit

Permalink
chore(tests): Rewrite some compile failure tests (noir-lang#2850)
Browse files Browse the repository at this point in the history
Co-authored-by: Yordan Madzhunkov <ymadzhunkov@gmail.com>
  • Loading branch information
2 people authored and Sakapoi committed Oct 19, 2023
1 parent f340b49 commit 7ccecbf
Show file tree
Hide file tree
Showing 49 changed files with 1,195 additions and 912 deletions.
7 changes: 6 additions & 1 deletion compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub struct DefCollector {
pub(crate) collected_traits_impls: Vec<UnresolvedTraitImpl>,
}

#[derive(Debug, Clone)]
pub enum CompilationError {
ParseError(ParserError),
DefinitionError(DefCollectorErrorKind),
Expand Down Expand Up @@ -506,7 +507,11 @@ fn add_method_to_struct_namespace(
let type_module = struct_type.id.local_module_id();
let module = &mut current_def_map.modules[type_module.0];
module.declare_function(name_ident.clone(), func_id).map_err(|(first_def, second_def)| {
DefCollectorErrorKind::Duplicate { typ: DuplicateType::Function, first_def, second_def }
DefCollectorErrorKind::Duplicate {
typ: DuplicateType::TraitImplementation,
first_def,
second_def,
}
})
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir/def_collector/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use thiserror::Error;

use std::fmt;

#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum DuplicateType {
Function,
Module,
Expand Down
4 changes: 1 addition & 3 deletions compiler/noirc_frontend/src/hir/def_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,7 @@ pub struct Contract {
/// Given a FileId, fetch the File, from the FileManager and parse it's content
pub fn parse_file(fm: &FileManager, file_id: FileId) -> (ParsedModule, Vec<ParserError>) {
let file = fm.fetch_file(file_id);
let (program, errors) = parse_program(file.source());

(program, errors)
parse_program(file.source())
}

impl std::ops::Index<LocalModuleId> for CrateDefMap {
Expand Down
Loading

0 comments on commit 7ccecbf

Please sign in to comment.