Commit 2efd0f4
committed
cgen: also materialize parenthesized string-slice sumtype casts via ADDR
The #27548 fix only treated a top-level `IndexExpr` with a `RangeExpr` as an
rvalue, but `ast.Expr.is_lvalue()` recurses through `ParExpr`, so a trivially
parenthesized slice (`Value((s[1..3]))`) still reported as an lvalue and took
the bare `&` path, reproducing the "address of an rvalue" C error.
Replace the inline top-level check with a small recursive helper that unwraps
parentheses, and add a regression test for the parenthesized form.1 parent 5d00023 commit 2efd0f4
2 files changed
Lines changed: 26 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5153 | 5153 | | |
5154 | 5154 | | |
5155 | 5155 | | |
| 5156 | + | |
| 5157 | + | |
| 5158 | + | |
| 5159 | + | |
| 5160 | + | |
| 5161 | + | |
| 5162 | + | |
| 5163 | + | |
| 5164 | + | |
| 5165 | + | |
| 5166 | + | |
5156 | 5167 | | |
5157 | 5168 | | |
5158 | 5169 | | |
| |||
5177 | 5188 | | |
5178 | 5189 | | |
5179 | 5190 | | |
5180 | | - | |
| 5191 | + | |
| 5192 | + | |
| 5193 | + | |
5181 | 5194 | | |
5182 | 5195 | | |
5183 | 5196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
| |||
17 | 23 | | |
18 | 24 | | |
19 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
20 | 32 | | |
21 | 33 | | |
22 | 34 | | |
| |||
0 commit comments