D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7874 - [CTFE] internal error: unsupported assignment (x OP= y) = z
Summary: [CTFE] internal error: unsupported assignment (x OP= y) = z
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P5 minor
Assignee: No Owner
URL:
Keywords: CTFE, pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2012-04-09 09:48 UTC by timon.gehr
Modified: 2015-01-21 13:49 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description timon.gehr 2012-04-09 09:48:43 UTC
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 Don 2012-04-17 01:43:48 UTC
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 SomeDude 2012-04-21 11:17:31 UTC
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 timon.gehr 2012-04-21 11:44:38 UTC
(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 SomeDude 2012-04-21 14:36:01 UTC
One could argue that the fact that such code is rejected is rather a good thing.
Comment 5 timon.gehr 2012-04-22 09:44:30 UTC
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 Kenji Hara 2015-01-20 16:51:39 UTC
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
Comment 7 github-bugzilla 2015-01-21 13:49:38 UTC
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).