Bug 15592 – Template specializations don't work in nested scope

Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-01-22T19:44:25Z
Last change time
2023-06-27T13:34:35Z
Assigned to
No Owner
Creator
Ali Cehreli

Comments

Comment #0 by acehreli — 2016-01-22T19:44:25Z
void main(){ void foo(T)() { } void foo(T : int)() { } struct S(T) { } struct S(T : int) { } } Error: declaration foo(T : int)() is already defined Error: declaration S(T : int) is already defined
Comment #1 by razvan.nitu1305 — 2023-06-27T13:34:35Z
Specializations have nothing to do with this. The spec clearly states that nested functions cannot be overloaded (point 3 of [1]). This codes compiles: ``` void main(){ void foo(T : int)() { } struct S(T : int) { } } ``` It has been argued in the past that this limitation should be lifted, however, Walter opposes it (I don't remember the reason). So closing this as WONTFIX. [1] https://dlang.org/spec/function.html#nested-declaration-order