Bug 21406 – CatAssign wrong evaluation/load order at run-time

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-11-19T09:11:15Z
Last change time
2022-07-21T08:18:53Z
Keywords
wrong-code
Assigned to
No Owner
Creator
Iain Buclaw

Comments

Comment #0 by ibuclaw — 2020-11-19T09:11:15Z
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.
Comment #1 by razvan.nitu1305 — 2022-07-08T10:47:16Z
This currently compiles and runs successfully (without the commented "FIX ME" line). @ibuclaw is that enough to close this test or do you expect that the commented line is also fixed?
Comment #2 by dlang-bot — 2022-07-20T11:00:23Z
@RazvanN7 created dlang/dmd pull request #14318 "Add test for issue 21406" mentioning this issue: - Add test for issue 21406 https://github.com/dlang/dmd/pull/14318
Comment #3 by dlang-bot — 2022-07-20T12:06:08Z
dlang/dmd pull request #14318 "Add test for issue 21406" was merged into master: - 88d093c5ea79323b8f0d81f94328e270c0b5e3d9 by RazvanN7: Add test for issue 21406 https://github.com/dlang/dmd/pull/14318