Closed mortenpi closed 2 years ago
I just discovered that the inconsistent evaluation is probably consistent with normal string interpolation:
julia> value = 1; "$(value), $(value + 1), $(value += 1), $(value += 1)"
"3, 2, 2, 3"
julia> let value = 1; "$(value), $(value + 1), $(value += 1), $(value += 1)"; end
"1, 2, 2, 3"
So I am not sure if CommonMark should fix this for cm""
, or stay consistent with normal string interpolation.
Ooh, very good point... I reckon best to keep the "fixed" behaviour you've added here rather than matching a bug upstream, which, hopefully, will get fixed at some point.
I noticed that the tests that parse this string
intermittently fail. It turns out that assignments in argument lists (which
cm""
depends on, when it constructs the vector of values) are problematic: https://github.com/JuliaLang/julia/issues/46251This changes the
cm""
macro such that the generated code evaluates the values one-by-one and pushes them into a vector that later gets passed to_interp!
, rather than constructing the vector in one go with a[ ... ]
expression. This should make sure that values are evaluated in a deterministic order.I split the commits to see if the MWE test also fails on CI systematically, but I think the PR should be squash-merged.