From 29e847768ae5d6fe7e631c668d23536729dbe8d8 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Thu, 4 Dec 2025 16:59:53 +1300 Subject: Allow macros with different arities to share argument names This commit includes the arity of a parent macro in the namespace of a macro argument, so that the assembler library can recognise that two macro implementations with different arities are not the same. This fixes an error where two implementations of a macro with the same name but different arity could not share argument names, because the arity of the parent macro wasn't being taken into account when checking for redefinitions. --- src/stages/compiler.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/stages/compiler.rs b/src/stages/compiler.rs index bc86589..4777fb4 100644 --- a/src/stages/compiler.rs +++ b/src/stages/compiler.rs @@ -119,7 +119,9 @@ impl SymbolParser { SymbolRoleDetailed::MacroDefinition, ); // Track that we're currently inside a macro definition. - self.macro_name = Some(definition.name.to_string()); + let macro_name = &definition.name; + let macro_args = definition.arguments.len(); + self.macro_name = Some(format!("{macro_name}::{macro_args}")); for argument in &definition.arguments { self.record_symbol( -- cgit v1.2.3-70-g09d2