mirror of
https://github.com/casey/just.git
synced 2024-11-25 15:34:13 +03:00
Fix type names in redefinition error message (#2353)
This commit is contained in:
parent
beef0e1a0f
commit
5fb514c1c6
@ -52,10 +52,10 @@ impl<'src> Analyzer<'src> {
|
|||||||
-> CompileResult<'src> {
|
-> CompileResult<'src> {
|
||||||
if let Some((first_type, original)) = definitions.get(name.lexeme()) {
|
if let Some((first_type, original)) = definitions.get(name.lexeme()) {
|
||||||
if !(*first_type == second_type && duplicates_allowed) {
|
if !(*first_type == second_type && duplicates_allowed) {
|
||||||
let (original, redefinition) = if name.line < original.line {
|
let ((first_type, second_type), (original, redefinition)) = if name.line < original.line {
|
||||||
(name, *original)
|
((second_type, *first_type), (name, *original))
|
||||||
} else {
|
} else {
|
||||||
(*original, name)
|
((*first_type, second_type), (*original, name))
|
||||||
};
|
};
|
||||||
|
|
||||||
return Err(redefinition.token.error(Redefinition {
|
return Err(redefinition.token.error(Redefinition {
|
||||||
@ -383,7 +383,7 @@ mod tests {
|
|||||||
line: 2,
|
line: 2,
|
||||||
column: 6,
|
column: 6,
|
||||||
width: 3,
|
width: 3,
|
||||||
kind: Redefinition { first_type: "alias", second_type: "recipe", name: "foo", first: 0 },
|
kind: Redefinition { first_type: "recipe", second_type: "alias", name: "foo", first: 0 },
|
||||||
}
|
}
|
||||||
|
|
||||||
analysis_error! {
|
analysis_error! {
|
||||||
|
@ -109,3 +109,21 @@ fn file_paths_not_in_subdir_are_absolute() {
|
|||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn redefinition_errors_properly_swap_types() {
|
||||||
|
Test::new()
|
||||||
|
.write("foo.just", "foo:")
|
||||||
|
.justfile("foo:\n echo foo\n\nmod foo 'foo.just'")
|
||||||
|
.status(EXIT_FAILURE)
|
||||||
|
.stderr(
|
||||||
|
"
|
||||||
|
error: Recipe `foo` defined on line 1 is redefined as a module on line 4
|
||||||
|
——▶ justfile:4:5
|
||||||
|
│
|
||||||
|
4 │ mod foo 'foo.just'
|
||||||
|
│ ^^^
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user