[Issue 241] New: Template function ICE

Oskar Linde oskar.lindeREM at OVEgmail.com
Thu Jul 6 08:44:56 PDT 2006


d-bugmail at puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=241
> 
>            Summary: Template function ICE
>            Product: D
>            Version: 0.162
>           Platform: PC
>         OS/Version: Linux
>             Status: NEW
>           Severity: normal
>           Priority: P2
>          Component: DMD
>         AssignedTo: bugzilla at digitalmars.com
>         ReportedBy: oskar.linde at gmail.com
> 
> 
> T func(T, T c = 1)(T x) { return x * c; }
> void main() { func(1.0); }
> 
> Generates (with DMD 0.162 linux):
> dmd: template.c:622: void TemplateDeclaration::declareParameter(Scope*,
> TemplateParameter*, Object*): Assertion `0' failed.
> 
> 

Upon closer inspection, it appears that using a template TypeParameter 
type as a value type doesn't work.

Both:

func!(double)(1.0);
and
func!(double,1)(1.0);

give: "template instance [...] does not match any template declaration"

I would expect

template(T,T c) {...}

to work for any T such that T is a valid value type, and in other cases 
generate an error message on instantiation saying something like "T is 
not a valid template value type".

If, on the other hand, the use of a template type as value parameter 
type is not meant to be allowed, an error message on template 
declaration would be helpful.

/Oskar



More information about the Digitalmars-d-bugs mailing list