Bug 567 – Example in spec uses conflicting templates

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P4
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-11-18T13:12:00Z
Last change time
2014-02-15T13:20:48Z
Keywords
diagnostic, spec
Assigned to
bugzilla
Creator
matti.niemenmaa+dbugzilla
Blocks
511, 677

Comments

Comment #0 by matti.niemenmaa+dbugzilla — 2006-11-18T13:12:20Z
The code below is directly from the "Specialization" section in the spec, with only empty template bodies and aliases added to make it syntactically valid. Evidently (according to the spec and the comments) this should work, so there shouldn't be a conflict: template Foo(T) {} template Foo(T:T*) {} template Foo(T, T) {} template Foo(T, U) {} template Foo(T, U:int) {} alias Foo!(long) a; // picks Foo(T) alias Foo!(long[]) b; // picks Foo(T), T is long[] alias Foo!(int*) c; // picks Foo(T*), T is int alias Foo!(long,long) d; // picks Foo(T, T) alias Foo!(long,short) e; // picks Foo(T, U) alias Foo!(long,int) f; // picks Foo(T, U:int) alias Foo!(int,int) g; // ambiguous - Foo(T, T) // or Foo(T, U:int) DMD crashes on the above after emitting the following: asdf.d(4): template asdf.Foo(T,U) conflicts with asdf.Foo(T) at asdf.d(1)
Comment #1 by bugzilla — 2006-11-30T03:28:40Z
Spec is wrong, will fix spec. Shouldn't crash.
Comment #2 by matti.niemenmaa+dbugzilla — 2006-12-03T04:01:49Z
DMD no longer crashes with version 0.176, but the spec remains incorrect.
Comment #3 by smjg — 2006-12-11T20:35:50Z
Under DMD 0.174: bz567.d(4): template bz567.Foo(T,U) conflicts with bz567.Foo(T) at bz567.d(1) bz567.d(3): Error: parameter 'T' multiply defined So it's Foo(T, U) and Foo(T, T) that conflict. But the fact that it mentions bz567.Foo(T) and line 1 looks like a bug. Commenting out every line except 3 or 4 gives the similar bz567.d(4): template bz567.Foo(T,U) conflicts with bz567.Foo(T,T) at bz567.d(3) bz567.d(3): Error: parameter 'T' multiply defined
Comment #4 by bugzilla — 2006-12-12T04:14:55Z
Fixed DMD 0.176