Skip to content

Commit

Permalink
Report clearer error if = is used instead of ==
Browse files Browse the repository at this point in the history
  • Loading branch information
ojwb committed Oct 22, 2021
1 parent 4ff3598 commit 5559db7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions compiler/analyser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,13 @@ static struct node * read_C(struct analyser * a) {
read_token(t);
int token = t->token;
switch (token) {
case c_assign:
count_error(a);
fprintf(stderr, "%s:%d: Expected relational operator (did you mean '=='?)\n",
t->file, t->line_number);
/* Assume it was == to try to avoid an error avalanche. */
token = c_eq;
/* FALLTHRU */
case c_eq:
case c_ne:
case c_gr:
Expand Down

0 comments on commit 5559db7

Please sign in to comment.