Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Improve error message for assignment rule in semantic analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
alxkzmn committed Aug 30, 2024
1 parent 63553ac commit d89c2d3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/compiler/semantic/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ fn assignment_rule(analyser: &mut Analyser, expr: &Statement<BigInt, Identifier>
}
} else if ids.len() != rhs.len() {
analyser.error(
"Number of identifiers and expressions in assignment should be equal".to_string(),
format!(
"Left hand side has {} identifier(s), but right hand side has {} expression(s)",
ids.len(),
rhs.len()
),
&expr.get_dsym(),
)
}
Expand Down Expand Up @@ -1260,7 +1264,7 @@ mod test {
}
}
",
r#"[SemErr { msg: "Number of identifiers and expressions in assignment should be equal", dsym: nofile:6:17 }]"#,
r#"[SemErr { msg: "Left hand side has 1 identifier(s), but right hand side has 2 expression(s)", dsym: nofile:6:17 }]"#,
);

do_test(
Expand All @@ -1273,7 +1277,7 @@ mod test {
}
}
",
r#"[SemErr { msg: "Number of identifiers and expressions in assignment should be equal", dsym: nofile:6:17 }]"#,
r#"[SemErr { msg: "Left hand side has 1 identifier(s), but right hand side has 2 expression(s)", dsym: nofile:6:17 }]"#,
);
}

Expand Down

0 comments on commit d89c2d3

Please sign in to comment.