aboutsummaryrefslogtreecommitdiffhomepage
path: root/parse.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-06-04 10:26:48 +0200
committerlemon <lsof@mailbox.org>2023-06-04 10:26:48 +0200
commit2075cfc9b395b413de1a540f6262e7b994907bee (patch)
tree2ee5114e0a5b288d40ac40e9d06f0e86157fd18f /parse.c
parentbd390afdf4eabfe13c1dd18bde23f4246ad73514 (diff)
fix associativity of assignment expressions
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/parse.c b/parse.c
index 20e517f..228f6c8 100644
--- a/parse.c
+++ b/parse.c
@@ -896,10 +896,11 @@ Postfix:
lex(pr, &tk);
ek = bintab[tk.t].t;
if (ek != ECOND) {
+ bool leftassoc = (bintab[tk.t].k & BCSET) == 0; /* only the assignment operators are right-associative */
/* ex OP rhs */
span.sl = tk.span.sl;
span.ex = ex.span.ex;
- rhs = exprparse(pr, opprec + 1);
+ rhs = exprparse(pr, opprec + leftassoc);
if (!joinspan(&span.ex, tk.span.ex) || !joinspan(&span.ex, rhs.span.ex))
span.ex = tk.span.ex;
ty = bintypecheck(&span, tk.t, &ex, &rhs);