diff --git a/src/dev_aid/lsp/tree_walk.rs b/src/dev_aid/lsp/tree_walk.rs index b05696e..fbd935a 100644 --- a/src/dev_aid/lsp/tree_walk.rs +++ b/src/dev_aid/lsp/tree_walk.rs @@ -214,7 +214,7 @@ impl<'linker, Visitor: FnMut(Span, LocationInfo<'linker>), Pruner: Fn(Span) -> b NameElem: From, { let target_name_elem = NameElem::from(global.id); - self.visit(global.total_span, LocationInfo::Global(target_name_elem)); + self.visit(global.name_span, LocationInfo::Global(target_name_elem)); for (id, template_arg) in global.template_args.iter_valids() { let target_link_info = self.linker.get_link_info(target_name_elem); self.visit( @@ -253,8 +253,8 @@ impl<'linker, Visitor: FnMut(Span, LocationInfo<'linker>), Pruner: Fn(Span) -> b ), ); } - WireReferenceRoot::NamedConstant(cst, span) => { - self.visit(*span, LocationInfo::Global(NameElem::Constant(cst.id))) + WireReferenceRoot::NamedConstant(cst) => { + self.walk_global_reference(NameElem::Module(md_id), &md.link_info, cst); } WireReferenceRoot::SubModulePort(port) => { if let Some(span) = port.port_name_span { diff --git a/src/errors.rs b/src/errors.rs index 39b8f66..5283fed 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -274,7 +274,7 @@ impl ErrorInfoObject for SubModuleInstance { if let Some((name, span)) = &self.name { (*span, format!("{name} declared here")) } else { - (self.module_ref.total_span, "Used here".to_owned()) + (self.module_ref.name_span, "Used here".to_owned()) } } } diff --git a/src/flattening/flatten.rs b/src/flattening/flatten.rs index 81ddd35..cc4ae17 100644 --- a/src/flattening/flatten.rs +++ b/src/flattening/flatten.rs @@ -72,7 +72,7 @@ impl PartialWireReference { let md = &ctx.globals[md_ref.id]; ctx.errors .error( - md_ref.total_span, + md_ref.name_span, format!( "Expected a Wire Reference, but found module '{}' instead", md.link_info.name @@ -268,14 +268,6 @@ impl<'l, 'errs> FlatteningContext<'l, 'errs> { assert!(template_inputs_to_visit.is_empty()); } - fn get_link_info_for(&self, found_global: NameElem) -> Option<&'l LinkInfo> { - Some(match found_global { - NameElem::Module(md_id) => &self.globals[md_id].link_info, - NameElem::Type(typ_id) => &self.globals[typ_id].link_info, - NameElem::Constant(_) => return None - }) - } - fn must_be_generative(&self, is_generative: bool, context: &str, span: Span) { if !is_generative { self.errors.error(span, format!("{context} must be a compile-time expression")); @@ -283,7 +275,7 @@ impl<'l, 'errs> FlatteningContext<'l, 'errs> { } fn flatten_template_args(&mut self, found_global: NameElem, has_template_args: bool, cursor: &mut Cursor) -> TemplateArgs { - let Some(link_info) = self.get_link_info_for(found_global) else {return FlatAlloc::new()}; + let link_info = self.globals.get_link_info(found_global); let full_object_name = link_info.get_full_name(); let mut template_arg_map : FlatAlloc, TemplateIDMarker> = link_info.template_arguments.map(|_| None); @@ -400,11 +392,11 @@ impl<'l, 'errs> FlatteningContext<'l, 'errs> { } // Global identifier - let [name_span] = name_path.as_slice() else { + let [name_span] = *name_path.as_slice() else { self.errors.todo(name_path[1], "Namespaces"); return LocalOrGlobal::NotFound(name_path[0]); }; - if let Some((global_id, total_span)) = self.globals.resolve_global(*name_span) { + if let Some(global_id) = self.globals.resolve_global(name_span) { // MUST Still be at field!("template_args") let template_span = template_args_used.then(|| BracketSpan::from_outer(cursor.span())); @@ -415,28 +407,28 @@ impl<'l, 'errs> FlatteningContext<'l, 'errs> { match global_id { NameElem::Module(id) => LocalOrGlobal::Module(GlobalReference { id, - total_span, + name_span, template_args, template_arg_types, template_span, }), NameElem::Type(id) => LocalOrGlobal::Type(GlobalReference { id, - total_span, + name_span, template_args, template_arg_types, template_span, }), NameElem::Constant(id) => LocalOrGlobal::Constant(GlobalReference { id, - total_span, + name_span, template_args, template_arg_types, template_span, }), } } else { - LocalOrGlobal::NotFound(*name_span) + LocalOrGlobal::NotFound(name_span) } }) } @@ -498,11 +490,11 @@ impl<'l, 'errs> FlatteningContext<'l, 'errs> { LocalOrGlobal::Module(module_ref) if ALLOW_MODULES => ModuleOrWrittenType::Module(module_ref), LocalOrGlobal::Module(module_ref) => { self.globals.not_expected_global_error(&module_ref, accepted_text); - ModuleOrWrittenType::WrittenType(WrittenType::Error(module_ref.total_span)) + ModuleOrWrittenType::WrittenType(WrittenType::Error(module_ref.name_span)) } LocalOrGlobal::Constant(constant_ref) => { self.globals.not_expected_global_error(&constant_ref, accepted_text); - ModuleOrWrittenType::WrittenType(WrittenType::Error(constant_ref.total_span)) + ModuleOrWrittenType::WrittenType(WrittenType::Error(constant_ref.name_span)) } LocalOrGlobal::NotFound(name_span) => { ModuleOrWrittenType::WrittenType(WrittenType::Error(name_span)) @@ -822,7 +814,7 @@ impl<'l, 'errs> FlatteningContext<'l, 'errs> { PartialWireReference::Error => None, PartialWireReference::GlobalModuleName(module_ref) => { let documentation = cursor.extract_gathered_comments(); - let interface_span = module_ref.total_span; + let interface_span = module_ref.get_total_span(); let submodule_decl = self.alloc_submodule_instruction(module_ref, None, documentation); Some(ModuleInterfaceReference { submodule_decl, @@ -937,7 +929,7 @@ impl<'l, 'errs> FlatteningContext<'l, 'errs> { if let Some(wr) = self.flatten_wire_reference(cursor).expect_wireref(self) { let mut is_comptime = match wr.root { WireReferenceRoot::LocalDecl(uuid, _span) => self.instructions[uuid].unwrap_wire_declaration().identifier_type.is_generative(), - WireReferenceRoot::NamedConstant(_, _) => true, + WireReferenceRoot::NamedConstant(_) => true, WireReferenceRoot::SubModulePort(_) => false, }; @@ -991,7 +983,7 @@ impl<'l, 'errs> FlatteningContext<'l, 'errs> { } }, LocalOrGlobal::Constant(cst_ref) => { - let root = WireReferenceRoot::NamedConstant(cst_ref, expr_span); + let root = WireReferenceRoot::NamedConstant(cst_ref); PartialWireReference::WireReference(WireReference { root, is_generative: true, @@ -1046,7 +1038,7 @@ impl<'l, 'errs> FlatteningContext<'l, 'errs> { match flattened_arr_expr { PartialWireReference::Error => PartialWireReference::Error, PartialWireReference::GlobalModuleName(md_ref) => { - self.errors.error(md_ref.total_span, "Ports or interfaces can only be accessed on modules that have been explicitly declared. Declare this submodule on its own line"); + self.errors.error(md_ref.get_total_span(), "Ports or interfaces can only be accessed on modules that have been explicitly declared. Declare this submodule on its own line"); PartialWireReference::Error } PartialWireReference::ModuleWithInterface { submodule_decl:_, submodule_name_span, interface:_, interface_name_span } => { diff --git a/src/flattening/mod.rs b/src/flattening/mod.rs index c4247fe..a0c7147 100644 --- a/src/flattening/mod.rs +++ b/src/flattening/mod.rs @@ -119,7 +119,7 @@ impl Module { pub fn get_instruction_span(&self, instr_id: FlatID) -> Span { match &self.link_info.instructions[instr_id] { - Instruction::SubModule(sm) => sm.module_ref.total_span, + Instruction::SubModule(sm) => sm.module_ref.get_total_span(), Instruction::FuncCall(fc) => fc.whole_func_span, Instruction::Declaration(decl) => decl.decl_span, Instruction::Wire(w) => w.span, @@ -254,7 +254,7 @@ impl WireReferencePathElement { #[derive(Debug)] pub enum WireReferenceRoot { LocalDecl(FlatID, Span), - NamedConstant(GlobalReference, Span), + NamedConstant(GlobalReference), SubModulePort(PortInfo), } @@ -262,7 +262,7 @@ impl WireReferenceRoot { pub fn get_root_flat(&self) -> Option { match self { WireReferenceRoot::LocalDecl(f, _) => Some(*f), - WireReferenceRoot::NamedConstant(_, _) => None, + WireReferenceRoot::NamedConstant(_) => None, WireReferenceRoot::SubModulePort(port) => Some(port.submodule_decl), } } @@ -417,8 +417,8 @@ impl WrittenType { match self { WrittenType::Error(total_span) | WrittenType::TemplateVariable(total_span, ..) - | WrittenType::Named(GlobalReference { total_span, .. }) | WrittenType::Array(total_span, _) => *total_span, + WrittenType::Named(global_ref) => global_ref.get_total_span() } } } diff --git a/src/flattening/typechecking.rs b/src/flattening/typechecking.rs index 4378958..d7651de 100644 --- a/src/flattening/typechecking.rs +++ b/src/flattening/typechecking.rs @@ -110,7 +110,7 @@ impl<'l, 'errs> TypeCheckingContext<'l, 'errs> { let decl_root = self.working_on.instructions[*id].unwrap_wire_declaration(); (decl_root.decl_span, self.errors.file) } - WireReferenceRoot::NamedConstant(cst, _) => { + WireReferenceRoot::NamedConstant(cst) => { let linker_cst = &self.globals[cst.id]; linker_cst.link_info.get_span_file() } @@ -142,7 +142,7 @@ impl<'l, 'errs> TypeCheckingContext<'l, 'errs> { let decl_root = self.working_on.instructions[*id].unwrap_wire_declaration(); decl_root.typ.clone() } - WireReferenceRoot::NamedConstant(cst, _) => { + WireReferenceRoot::NamedConstant(cst) => { let linker_cst = &self.globals[cst.id]; let decl = linker_cst.link_info.instructions[linker_cst.output_decl].unwrap_wire_declaration(); let typ = AbstractType::Unknown(self.type_checker.alloc_typ_variable()); @@ -201,9 +201,9 @@ impl<'l, 'errs> TypeCheckingContext<'l, 'errs> { } Instruction::Wire(_) => {} Instruction::Write(conn) => { - let (decl, file) = match conn.to.root { + let (decl, file) = match &conn.to.root { WireReferenceRoot::LocalDecl(decl_id, _) => { - let decl = self.working_on.instructions[decl_id].unwrap_wire_declaration(); + let decl = self.working_on.instructions[*decl_id].unwrap_wire_declaration(); if decl.read_only { self.errors .error(conn.to_span, format!("'{}' is read-only", decl.name)) @@ -211,8 +211,8 @@ impl<'l, 'errs> TypeCheckingContext<'l, 'errs> { } (decl, self.errors.file) } - WireReferenceRoot::NamedConstant(_, span) => { - self.errors.error(span, "Cannot assign to a global"); + WireReferenceRoot::NamedConstant(cst) => { + self.errors.error(cst.name_span, "Cannot assign to a global"); return; } WireReferenceRoot::SubModulePort(port) => { @@ -538,17 +538,27 @@ pub fn apply_types( // Post type application. Solidify types and flag any remaining AbstractType::Unknown for (_id, inst) in working_on.link_info.instructions.iter_mut() { match inst { - Instruction::Wire(w) => type_checker.finalize_type(types, &mut w.typ, w.span, errors), + Instruction::Wire(w) => { + type_checker.finalize_type(types, &mut w.typ, w.span, errors); + if let WireSource::WireRef(wr) = &mut w.source { + if let WireReferenceRoot::NamedConstant(cst) = &mut wr.root { + type_checker.finalize_global_ref(types, cst, errors); + } + } + } Instruction::Declaration(decl) => type_checker.finalize_type(types, &mut decl.typ, decl.name_span, errors), - Instruction::Write(Write { to_type, to_span, .. }) => type_checker.finalize_type(types, to_type, *to_span, errors), + Instruction::Write(Write { to_type, to_span, to, .. }) => { + type_checker.finalize_type(types, to_type, *to_span, errors); + if let WireReferenceRoot::NamedConstant(cst) = &mut to.root { + type_checker.finalize_global_ref(types, cst, errors); + } + } // TODO Submodule domains may not be crossed either? Instruction::SubModule(sm) => { for (_domain_id_in_submodule, domain_assigned_to_it_here) in &mut sm.local_interface_domains { type_checker.finalize_domain_type(domain_assigned_to_it_here); } - for (_template_id, template_type) in &mut sm.module_ref.template_arg_types { - type_checker.finalize_abstract_type(types, template_type, sm.module_ref.total_span, errors); - } + type_checker.finalize_global_ref(types, &mut sm.module_ref, errors); } _other => {} } diff --git a/src/flattening/walk.rs b/src/flattening/walk.rs index 35f7dc6..e187fa4 100644 --- a/src/flattening/walk.rs +++ b/src/flattening/walk.rs @@ -11,7 +11,7 @@ impl WireSource { WireSource::WireRef(wire_ref) => { match &wire_ref.root { WireReferenceRoot::LocalDecl(decl_id, _) => func(*decl_id), - WireReferenceRoot::NamedConstant(_, _) => {} + WireReferenceRoot::NamedConstant(_) => {} WireReferenceRoot::SubModulePort(submod_port) => { func(submod_port.submodule_decl) } diff --git a/src/instantiation/execute.rs b/src/instantiation/execute.rs index 0443f72..d729120 100644 --- a/src/instantiation/execute.rs +++ b/src/instantiation/execute.rs @@ -203,7 +203,7 @@ impl<'fl, 'l> InstantiationContext<'fl, 'l> { SubModuleOrWire::SubModule(_) => unreachable!(), SubModuleOrWire::Unnasigned => unreachable!(), }, - WireReferenceRoot::NamedConstant(cst, _) => { + WireReferenceRoot::NamedConstant(cst) => { let cst = &self.linker.constants[cst.id]; RealWireRefRoot::Constant(cst.val.clone()) } @@ -357,7 +357,7 @@ impl<'fl, 'l> InstantiationContext<'fl, 'l> { &WireReferenceRoot::LocalDecl(decl_id, _span) => { self.generation_state.get_generation_value(decl_id)?.clone() } - WireReferenceRoot::NamedConstant(cst, _span) => { + WireReferenceRoot::NamedConstant(cst) => { self.linker.constants[cst.id].get_value().clone() } &WireReferenceRoot::SubModulePort(_) => { diff --git a/src/instantiation/mod.rs b/src/instantiation/mod.rs index cf1ad4e..f29651d 100644 --- a/src/instantiation/mod.rs +++ b/src/instantiation/mod.rs @@ -309,7 +309,7 @@ impl<'fl, 'l> InstantiationContext<'fl, 'l> { if !check_all_template_args_valid( &self.errors, - submod_instr.module_ref.total_span, + submod_instr.module_ref.get_total_span(), &sub_module.link_info, &sm.template_args, ) { @@ -344,7 +344,7 @@ impl<'fl, 'l> InstantiationContext<'fl, 'l> { let source_code_port = &sub_module.ports[port_id]; self.errors .warn( - submod_instr.module_ref.total_span, + submod_instr.module_ref.get_total_span(), format!("Unused port '{}'", source_code_port.name), ) .info_obj_different_file( @@ -396,7 +396,7 @@ impl<'fl, 'l> InstantiationContext<'fl, 'l> { sm.instance = Some(instance); } else { self.errors.error( - submod_instr.module_ref.total_span, + submod_instr.module_ref.get_total_span(), "Error instantiating submodule", ); success = false; diff --git a/src/linker/resolver.rs b/src/linker/resolver.rs index e654e86..0a79db1 100644 --- a/src/linker/resolver.rs +++ b/src/linker/resolver.rs @@ -75,14 +75,14 @@ impl<'linker> GlobalResolver<'linker> { } /// SAFETY: Files are never touched, and as long as this object is managed properly linker will also exist long enough. - pub fn resolve_global<'slf>(&'slf self, name_span: Span) -> Option<(NameElem, Span)> { + pub fn resolve_global<'slf>(&'slf self, name_span: Span) -> Option { let name = &self.file_data.file_text[name_span]; let mut resolved_globals = self.resolved_globals.borrow_mut(); match self.linker.global_namespace.get(name) { Some(NamespaceElement::Global(found)) => { resolved_globals.referenced_globals.push(*found); - Some((*found, name_span)) + Some(*found) } Some(NamespaceElement::Colission(coll)) => { resolved_globals.all_resolved = false; @@ -123,7 +123,7 @@ impl<'linker> GlobalResolver<'linker> { let name = &info.full_name; let global_type = info.named_type; let err_ref = self.errors.error( - global_ref.total_span, + global_ref.name_span, format!("{name} is not a {expected}, it is a {global_type} instead!"), ); err_ref.info(info.location, "Defined here"); diff --git a/src/typing/abstract_type.rs b/src/typing/abstract_type.rs index 328849e..8f8dc50 100644 --- a/src/typing/abstract_type.rs +++ b/src/typing/abstract_type.rs @@ -4,7 +4,7 @@ use crate::value::Value; use std::ops::Deref; -use super::template::{TemplateAbstractTypes, TemplateInputs}; +use super::template::{GlobalReference, TemplateAbstractTypes, TemplateInputs}; use super::type_inference::{DomainVariableID, DomainVariableIDMarker, TypeSubstitutor, TypeVariableID, TypeVariableIDMarker}; use crate::flattening::{BinaryOperator, StructType, TypingAllocator, UnaryOperator, WrittenType}; use crate::linker::get_builtin_type; @@ -342,4 +342,11 @@ impl TypeUnifier { self.finalize_domain_type(&mut typ.domain); self.finalize_abstract_type(types, &mut typ.typ, span, errors); } + + pub fn finalize_global_ref(&mut self, types: &ArenaAllocator, global_ref: &mut GlobalReference, errors: &ErrorCollector) { + let global_ref_span = global_ref.get_total_span(); + for (_template_id, template_type) in &mut global_ref.template_arg_types { + self.finalize_abstract_type(types, template_type, global_ref_span, errors); + } + } } diff --git a/src/typing/template.rs b/src/typing/template.rs index 55a9d81..857245d 100644 --- a/src/typing/template.rs +++ b/src/typing/template.rs @@ -5,13 +5,23 @@ use crate::{flattening::WrittenType, linker::LinkInfo, value::TypedValue}; #[derive(Debug)] pub struct GlobalReference { - pub total_span: Span, + pub name_span: Span, pub id: ID, pub template_args: TemplateArgs, pub template_arg_types: TemplateAbstractTypes, pub template_span: Option, } +impl GlobalReference { + pub fn get_total_span(&self) -> Span { + let mut result = self.name_span; + if let Some(template_span) = self.template_span { + result = Span::new_overarching(result, template_span.outer_span()); + } + result + } +} + #[derive(Debug)] pub struct TemplateInput { pub name: String, diff --git a/test.sus b/test.sus index fc6fc3c..dfef6b9 100644 --- a/test.sus +++ b/test.sus @@ -932,3 +932,26 @@ module useModuleWithBadInterface { xyz[3] = true } + + +const int SUM_UP #(int SIZE, int[SIZE] DATA) { + SUM_UP = 0 + for I in 0..SIZE { + SUM_UP = SUM_UP + DATA[I] + } +} + +__builtin__ const T dont_care #(T) {} + +module m { + gen int[5] DATA + DATA[0] = 2 + DATA[1] = 2 + DATA[2] = 2 + DATA[3] = 2 + DATA[4] = 5 + + gen int X = SUM_UP #(SIZE: 4, DATA, BEEEP: 3) + + int #(ABC) x +} diff --git a/test.sus_errors.txt b/test.sus_errors.txt index 7617efe..a652cf4 100644 --- a/test.sus_errors.txt +++ b/test.sus_errors.txt @@ -6,8 +6,8 @@ Warning: Unused port 'push' │ ╰─── Port 'push' declared here │ 86 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f - │ ──┬─ ┬ - │ ╰────────────────────────────────────────────── Unused port 'push' + │ ──────────────────────┬────────────────────── ┬ + │ ╰────────────────────────── Unused port 'push' │ │ │ ╰── f declared here ────╯ @@ -19,8 +19,8 @@ Warning: Unused port 'data_in' │ ╰───── Port 'data_in' declared here │ 86 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f - │ ──┬─ ┬ - │ ╰────────────────────────────────────────────── Unused port 'data_in' + │ ──────────────────────┬────────────────────── ┬ + │ ╰────────────────────────── Unused port 'data_in' │ │ │ ╰── f declared here ────╯ @@ -32,8 +32,8 @@ Warning: Unused port 'ready' │ ╰──── Port 'ready' declared here │ 86 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f - │ ──┬─ ┬ - │ ╰────────────────────────────────────────────── Unused port 'ready' + │ ──────────────────────┬────────────────────── ┬ + │ ╰────────────────────────── Unused port 'ready' │ │ │ ╰── f declared here ────╯ @@ -45,8 +45,8 @@ Warning: Unused port 'pop' │ ╰─── Port 'pop' declared here │ 86 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f - │ ──┬─ ┬ - │ ╰────────────────────────────────────────────── Unused port 'pop' + │ ──────────────────────┬────────────────────── ┬ + │ ╰────────────────────────── Unused port 'pop' │ │ │ ╰── f declared here ────╯ @@ -58,8 +58,8 @@ Warning: Unused port 'data_valid' │ ╰────── Port 'data_valid' declared here │ 86 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f - │ ──┬─ ┬ - │ ╰────────────────────────────────────────────── Unused port 'data_valid' + │ ──────────────────────┬────────────────────── ┬ + │ ╰────────────────────────── Unused port 'data_valid' │ │ │ ╰── f declared here ────╯ @@ -71,8 +71,8 @@ Warning: Unused port 'data_out' │ ╰───── Port 'data_out' declared here │ 86 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f - │ ──┬─ ┬ - │ ╰────────────────────────────────────────────── Unused port 'data_out' + │ ──────────────────────┬────────────────────── ┬ + │ ╰────────────────────────── Unused port 'data_out' │ │ │ ╰── f declared here ────╯ @@ -926,8 +926,8 @@ Error: Could not fully figure out the type of this object. type_variable_12 ╭─[test.sus:775:2] │ 775 │ FIFO #(BITWIDTH: 4) badoop - │ ──┬─ - │ ╰─── Could not fully figure out the type of this object. type_variable_12 + │ ─────────┬───────── + │ ╰─────────── Could not fully figure out the type of this object. type_variable_12 ─────╯ Warning: Unused Variable: This variable does not affect the output ports of this module ╭─[test.sus:766:22] @@ -954,8 +954,8 @@ Error: Could not fully figure out the type of this object. type_variable_1 ╭─[test.sus:779:2] │ 779 │ test #(MY_INPUT: 3) test_mod - │ ──┬─ - │ ╰─── Could not fully figure out the type of this object. type_variable_1 + │ ─────────┬───────── + │ ╰─────────── Could not fully figure out the type of this object. type_variable_1 ─────╯ Warning: Unused port 'o' ╭─[test.sus:791:2] @@ -965,8 +965,8 @@ Warning: Unused port 'o' │ ╰── Port 'o' declared here │ 791 │ tinyTestMod #(beep: 3) a - │ ─────┬───── ┬ - │ ╰──────────────────── Unused port 'o' + │ ───────────┬────────── ┬ + │ ╰────────────── Unused port 'o' │ │ │ ╰── a declared here ─────╯ @@ -978,8 +978,8 @@ Warning: Unused port 'o' │ ╰── Port 'o' declared here │ 792 │ tinyTestMod #(beep: 4) b - │ ─────┬───── ┬ - │ ╰──────────────────── Unused port 'o' + │ ───────────┬────────── ┬ + │ ╰────────────── Unused port 'o' │ │ │ ╰── b declared here ─────╯ @@ -991,8 +991,8 @@ Warning: Unused port 'o' │ ╰── Port 'o' declared here │ 793 │ tinyTestMod #(beep: 3) c - │ ─────┬───── ┬ - │ ╰──────────────────── Unused port 'o' + │ ───────────┬────────── ┬ + │ ╰────────────── Unused port 'o' │ │ │ ╰── c declared here ─────╯ @@ -1182,3 +1182,69 @@ Warning: Unused Variable: This variable does not affect the output ports of this │ ─┬─ │ ╰─── Unused Variable: This variable does not affect the output ports of this module ─────╯ +Error: BEEEP is not a valid template argument of ::SUM_UP + ╭─[test.sus:954:38] + │ + 937 │ const int SUM_UP #(int SIZE, int[SIZE] DATA) { + │ ───┬── + │ ╰──── 'SUM_UP' defined here + │ + 954 │ gen int X = SUM_UP #(SIZE: 4, DATA, BEEEP: 3) + │ ──┬── + │ ╰──── BEEEP is not a valid template argument of ::SUM_UP +─────╯ +Error: ABC is not a valid template argument of ::int + ╭─[test.sus:956:8] + │ + 956 │ int #(ABC) x + │ ─┬─ + │ ╰─── ABC is not a valid template argument of ::int + │ + ├─[/home/lennart/Desktop/sus-compiler/target/debug/share/sus_compiler/std/core.sus:28:20] + │ + 28 │ __builtin__ struct int {} + │ ─┬─ + │ ╰─── 'int' defined here +─────╯ +Error: ABC does not name a Type or a Value. + ╭─[test.sus:956:8] + │ + 956 │ int #(ABC) x + │ ─┬─ + │ ╰─── ABC does not name a Type or a Value. +─────╯ +Error: Could not fully figure out the type of this object. type_variable_21 + ╭─[test.sus:954:14] + │ + 954 │ gen int X = SUM_UP #(SIZE: 4, DATA, BEEEP: 3) + │ ────────────────┬──────────────── + │ ╰────────────────── Could not fully figure out the type of this object. type_variable_21 +─────╯ +Error: Could not fully figure out the type of this object. type_variable_22 + ╭─[test.sus:954:14] + │ + 954 │ gen int X = SUM_UP #(SIZE: 4, DATA, BEEEP: 3) + │ ────────────────┬──────────────── + │ ╰────────────────── Could not fully figure out the type of this object. type_variable_22 +─────╯ +Warning: Unused Variable: This variable does not affect the output ports of this module + ╭─[test.sus:947:13] + │ + 947 │ gen int[5] DATA + │ ──┬─ + │ ╰─── Unused Variable: This variable does not affect the output ports of this module +─────╯ +Warning: Unused Variable: This variable does not affect the output ports of this module + ╭─[test.sus:954:10] + │ + 954 │ gen int X = SUM_UP #(SIZE: 4, DATA, BEEEP: 3) + │ ┬ + │ ╰── Unused Variable: This variable does not affect the output ports of this module +─────╯ +Warning: Unused Variable: This variable does not affect the output ports of this module + ╭─[test.sus:956:13] + │ + 956 │ int #(ABC) x + │ ┬ + │ ╰── Unused Variable: This variable does not affect the output ports of this module +─────╯ diff --git a/test.sus_output.txt b/test.sus_output.txt index 1d90d1f..e6632c8 100644 --- a/test.sus_output.txt +++ b/test.sus_output.txt @@ -104,6 +104,9 @@ TREE SITTER module! use_no_main_interface TREE SITTER module! moduleWithBadDeclaration TREE SITTER module! moduleWithBadInterface TREE SITTER module! useModuleWithBadInterface +TREE SITTER module! SUM_UP +TREE SITTER module! dont_care +TREE SITTER module! m Typechecking DualPortMem Typechecking UseDualPortMem Typechecking FIFO @@ -205,6 +208,7 @@ Typechecking use_no_main_interface Typechecking moduleWithBadDeclaration Typechecking moduleWithBadInterface Typechecking useModuleWithBadInterface +Typechecking m Instantiating UseDualPortMem Instantiating submodules for UseDualPortMem Instantiating DualPortMem @@ -570,3 +574,4 @@ Not Instantiating use_no_main_interface due to flattening errors Not Instantiating moduleWithBadDeclaration due to flattening errors Not Instantiating moduleWithBadInterface due to flattening errors Not Instantiating useModuleWithBadInterface due to flattening errors +Not Instantiating m due to flattening errors