[Issue 21406] New: CatAssign wrong evaluation/load order at run-time
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Nov 19 09:11:15 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21406
Issue ID: 21406
Summary: CatAssign wrong evaluation/load order at run-time
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: critical
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: ibuclaw at gdcproject.org
This test should pass, but currently doesn't.
---
auto cat11ret3(T)(ref T s)
{
s ~= 11;
return [3];
}
void main()
{
static auto test1(int[] val) { val ~= cat11ret3(val); return val; }
assert(test1([1]) == [1, 11, 3]);
static assert(test1([1]) == [1, 11, 3]);
static auto test2(int[] val) { val = val ~ cat11ret3(val); return val; }
// FIXME: assert(test2([1]) == [1, 3]);
static assert(test2([1]) == [1, 3]);
static auto test3(int[] val) { (val ~= 7) ~= cat11ret3(val); return val; }
assert(test3([2]) == [2, 7, 11, 3]);
static assert(test3([2]) == [2, 7, 11, 3]);
static auto test4(int[] val) { (val ~= cat11ret3(val)) ~= 7; return val; }
assert(test4([2]) == [2, 11, 3, 7]);
static assert(test4([2]) == [2, 11, 3, 7]);
}
---
1. test4 is blocked by issue 21403.
2. test2 is a FIXME as per runnable/evalorder.d
https://github.com/dlang/dmd/blob/4208bfc30170b5272bb611433234acfd9230a631/test/runnable/evalorder.d#L55-L57
3. This test should be added to runnable/evalorder.d once dmd is able to both
compile it, and it passes both CTFE and run-time asserts.
--
More information about the Digitalmars-d-bugs
mailing list