Closed andrey-golubev closed 2 years ago
The patch is far from ideal, there should probably be a better way to fix this. And I see at least one other case where !is_lvalue(true, ...)
code is used - in ExpBinary
check. Should this also be updated somehow?
Ping @vpisarev. Btw, do you accept contributions at this stage at all?
@andrey-golubev, thank you! And sorry for a big delay. For now the pull requests are very rare, so I'm not get used yet to check this tab of the project on a regular basis :) I simply did not notice it. The patch is definitely useful. As for the example, changing val min_val = X[0]
to var min_val = X[0]
should make it compile and work as expected, or you can use more functional style with fold:
fun min(X: 't[]): 't =
fold min_val = X[0] for x <- X {min(min_val, x)}
is_lvalue
accepts a mutability flag and (among other things) decides whether to returntrue
orfalse
based on that. This in turn makes certain errors fairly cryptic. Consider:min_val
looks fairly l-value to me (in C++ terms at least), but it isval
which makes it immutable and so we cannot re-assign to it.