Bug 15352 – template arguments matching error with delegates
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-11-17T15:03:00Z
Last change time
2016-01-03T14:02:29Z
Keywords
ice, pull, rejects-valid
Assigned to
nobody
Creator
incsall
Comments
Comment #0 by incsall — 2015-11-17T15:03:54Z
struct S(T, T delegate(uint idx) supplier)
{
}
auto make1(T, T delegate(uint idx) supplier)()
{
enum local = supplier; // allows to avoid an error
S!(T, local) ret;
return ret;
}
auto make2(T, T delegate(uint idx) supplier)()
{
S!(T, supplier) ret; // Error: template instance S!(uint, __dgliteral1) does not match template declaration S(T, uint delegate(uint idx) supplier)
return ret;
}
unittest
{
enum dg = delegate(uint idx) => idx;
S!(uint, dg) s;
auto v = make1!(uint, dg)();
v = make2!(uint, dg)(); // throws compilation error
}
DMD32 D Compiler v2.069.0
Comment #1 by k.hara.pg — 2015-11-19T15:34:55Z
With a debug build dmd, the test case will hit a dmd internal assertion.
DMD v2.069 DEBUG
[email protected](524): Assertion failure
----------------
0x0058599B in _d_assert
0x0044BB66 in StructDeclaration at c:\d2home\dmd2\src\dmd\src\dstruct.d(524)
0x0045D4FD in TemplateInstance at c:\d2home\dmd2\src\dmd\src\dtemplate.d(7557)
0x0045D554 in TemplateInstance at c:\d2home\dmd2\src\dmd\src\dtemplate.d(7573)
0x00459E8E in TemplateInstance at c:\d2home\dmd2\src\dmd\src\dtemplate.d(5769)
0x0045A377 in TemplateInstance at c:\d2home\dmd2\src\dmd\src\dtemplate.d(5956)
0x004BA921 in TypeInstance at c:\d2home\dmd2\src\dmd\src\mtype.d(7381)
0x004BA9CE in TypeInstance at c:\d2home\dmd2\src\dmd\src\mtype.d(7403)
0x00429769 in VarDeclaration at c:\d2home\dmd2\src\dmd\src\declaration.d(1153)
0x0046E03F in DeclarationExp at c:\d2home\dmd2\src\dmd\src\expression.d(6590)
0x004DBA33 in ExpStatement at c:\d2home\dmd2\src\dmd\src\statement.d(1143)
0x004DC36E in CompoundStatement at c:\d2home\dmd2\src\dmd\src\statement.d(1421)
0x00487619 in FuncDeclaration at c:\d2home\dmd2\src\dmd\src\func.d(1604)
0x0045A62C in TemplateInstance at c:\d2home\dmd2\src\dmd\src\dtemplate.d(6048)
0x0045D5A4 in TemplateInstance at c:\d2home\dmd2\src\dmd\src\dtemplate.d(7588)
0x0045A00A in TemplateInstance at c:\d2home\dmd2\src\dmd\src\dtemplate.d(5838)
0x0045A377 in TemplateInstance at c:\d2home\dmd2\src\dmd\src\dtemplate.d(5956)
0x0046B0E3 in ScopeExp at c:\d2home\dmd2\src\dmd\src\expression.d(5323)
0x00474002 in CallExp at c:\d2home\dmd2\src\dmd\src\expression.d(8939)
0x0049C6FF in ExpInitializer at c:\d2home\dmd2\src\dmd\src\init.d(775)
0x004296A8 in VarDeclaration at c:\d2home\dmd2\src\dmd\src\declaration.d(1129)
0x0046E03F in DeclarationExp at c:\d2home\dmd2\src\dmd\src\expression.d(6590)
0x004DBA33 in ExpStatement at c:\d2home\dmd2\src\dmd\src\statement.d(1143)
0x004DC36E in CompoundStatement at c:\d2home\dmd2\src\dmd\src\statement.d(1421)
0x00487619 in FuncDeclaration at c:\d2home\dmd2\src\dmd\src\func.d(1604)
0x00444774 in Module at c:\d2home\dmd2\src\dmd\src\dmodule.d(1038)
0x004ACEEA in tryMain at c:\d2home\dmd2\src\dmd\src\mars.d(1515)
0x004AD79F in _Dmain at c:\d2home\dmd2\src\dmd\src\mars.d(1693)
0x00586C36 in D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
0x00586C0B in void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll()
0x00586B23 in _d_run_main
0x004ADAE4 in main
0x0059AFCD in mainCRTStartup
0x7595337A in BaseThreadInitThunk
0x776D9882 in RtlInitializeExceptionChain
0x776D9855 in RtlInitializeExceptionChain