From 719c08acf9f854902b80cd3fae066397835621e8 Mon Sep 17 00:00:00 2001 From: Marc Addeo Date: Sat, 7 Sep 2024 11:10:44 -0400 Subject: [PATCH] Fix ordering of types when reporting redefinitions The original and redefined Name's were being properly swapped, but their types weren't being swapped. This caused the error to report on the wrong lines when the redefinition was between two different types, i.e. alias and recipe. Closes #2350 --- src/analyzer.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/analyzer.rs b/src/analyzer.rs index 64c8fdc6ef..8a6b8eed36 100644 --- a/src/analyzer.rs +++ b/src/analyzer.rs @@ -52,10 +52,10 @@ impl<'src> Analyzer<'src> { -> CompileResult<'src> { if let Some((first_type, original)) = definitions.get(name.lexeme()) { if !(*first_type == second_type && duplicates_allowed) { - let (original, redefinition) = if name.line < original.line { - (name, *original) + let ((first_type, second_type), (original, redefinition)) = if name.line < original.line { + ((second_type, *first_type), (name, *original)) } else { - (*original, name) + ((*first_type, second_type), (*original, name)) }; return Err(redefinition.token.error(Redefinition {