Skip to content

Commit

Permalink
Fix ordering of types when reporting redefinitions
Browse files Browse the repository at this point in the history
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 casey#2350
  • Loading branch information
marcaddeo committed Sep 10, 2024
1 parent 0f481e2 commit 719c08a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 719c08a

Please sign in to comment.