DMD 2.058, 2.059head: int foo(int x){return ++x=1;} enum bar = foo; Error: CTFE internal error: unsupported assignment (x++ , x) = 1
Applies to many forms of op= assignment, including some cases of ref assignment. Eg. int foo(int[] x){ auto b = (x~=x)=[1,2,3]; return 3; } enum bar = foo([7,5]);
Actually, the first example gives on 2.059 PS E:\DigitalMars\dmd2\samples> dmd -c bug bug.d(2): Error: function bug.foo (int x) is not callable using argument types () bug.d(2): Error: expected 1 function arguments, not 0
(In reply to comment #2) > Actually, the first example gives on 2.059 > > PS E:\DigitalMars\dmd2\samples> dmd -c bug > bug.d(2): Error: function bug.foo (int x) is not callable using argument types > () > bug.d(2): Error: expected 1 function arguments, not 0 That is a typo. Fixed test case: int foo(int x){return ++x=1;} enum bar = foo(0);
One could argue that the fact that such code is rejected is rather a good thing.
That is not what this bug report is about. One can never argue that an ICE and spitting out of internal IR are good things.
Fixed in 2.067a git-head, by: https://github.com/D-Programming-Language/dmd/pull/4227 Test case addition: https://github.com/D-Programming-Language/dmd/pull/4319
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/8be17b6a7b715faeb9321afba21623eaf5cca87c fix Issue 7874 - [CTFE] internal error: unsupported assignment (x OP= y) = z Fixed in PR #4227 (22badb69bd07f013b96383ae4e07dd93cf12d115).