Bug 7874 – [CTFE] internal error: unsupported assignment (x OP= y) = z

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P5
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-04-09T09:48:00Z
Last change time
2015-01-21T13:49:42Z
Keywords
CTFE, pull, rejects-valid
Assigned to
nobody
Creator
timon.gehr

Comments

Comment #0 by timon.gehr — 2012-04-09T09:48:43Z
DMD 2.058, 2.059head: int foo(int x){return ++x=1;} enum bar = foo; Error: CTFE internal error: unsupported assignment (x++ , x) = 1
Comment #1 by clugdbug — 2012-04-17T01:43:48Z
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]);
Comment #2 by lovelydear — 2012-04-21T11:17:31Z
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
Comment #3 by timon.gehr — 2012-04-21T11:44:38Z
(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);
Comment #4 by lovelydear — 2012-04-21T14:36:01Z
One could argue that the fact that such code is rejected is rather a good thing.
Comment #5 by timon.gehr — 2012-04-22T09:44:30Z
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.
Comment #6 by k.hara.pg — 2015-01-20T16:51:39Z
Comment #7 by github-bugzilla — 2015-01-21T13:49:38Z
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).