Bug 13202 – Don't allow silent shadowing of type properties

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2014-07-25T01:05:00Z
Last change time
2014-07-29T15:48:51Z
Assigned to
nobody
Creator
davidsp

Comments

Comment #0 by davidsp — 2014-07-25T01:05:13Z
A class can accidentally overwrite a type property like T.init by defining a method init(). This shadowing is silently accepted by the compiler: class A { void init() {} } void t(T)() { auto x = T.init; } int main(string[] args) { t!A(); } -> test.d(10): Error: need 'this' for 'init' of type 'void()'. The bug is more: "Don't allow shadowing of type properties". auto x = T.init; should always be the appropriate initialization value, otherwise templates cannot savely use T.init if they allow a class or struct to be specified.
Comment #1 by davidsp — 2014-07-29T15:48:51Z
*** This issue has been marked as a duplicate of issue 7066 ***