Bug 9569 – 'alias this' syntax is not accepted by dmd

Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-22T09:25:00Z
Last change time
2013-11-09T02:31:30Z
Keywords
pull, spec
Assigned to
andrej.mitrovich
Creator
acehreli

Comments

Comment #0 by acehreli — 2013-02-22T09:25:51Z
struct Test { int i; alias this = i; // <-- Compilation error } void main() {} The compiler says: deneme.d(121089): Error: no identifier for declarator this deneme.d(121089): Error: alias cannot have initializer
Comment #1 by bearophile_hugs — 2013-02-22T09:36:44Z
This is working as designed, and probably should be closed. See also: http://forum.dlang.org/thread/[email protected] https://github.com/D-Programming-Language/dmd/issues/1413
Comment #2 by andrej.mitrovich — 2013-02-22T09:58:26Z
This is a spec issue covered with http://d.puremagic.com/issues/show_bug.cgi?id=9569
Comment #3 by andrej.mitrovich — 2013-02-22T10:06:44Z
Comment #4 by pr — 2013-02-23T14:00:38Z
We have a one alias beast, so now will have two beast... after month three beast ... (period) ... nth beast. Bad idea. Alias this used like class inheritance is bad idea too, because it's not a class inheritance. One syntax, one alias beast - it's good. About multiple alias this: alias this = ...; alias this = ...; ... alias this = ...; It's good because many uses of alias this is not desirable (although allowed) and people will think twice to use this feature. And I think it's more demonstrable when I want to show what I was mean when put it (alias this) into source code.
Comment #5 by verylonglogin.reg — 2013-11-09T02:31:30Z
(In reply to comment #4) > One syntax, one alias beast - it's good. `alias this = ...;` is reserved for aliasing of superclass constructors. See e.g. discussion of https://github.com/D-Programming-Language/dmd/pull/1341 Also documentation is correct now and the error is improved: --- Error: Cannot use syntax 'alias this = i', use 'alias i this' instead ---