﻿id	summary	reporter	owner	description	type	status	priority	component	version	resolution	keywords	cc
185	Cannot declare generic struct with zero type parameters	mlbrooks		"Wishing for:
{{{
forall ( | {void fun();} ) {

    struct thing {};

    void ?{}( thing & this ) {
        fun();
    }
}

void fun() {
    printf(""this is fun\n"");
}

int main() {
   thing x;
}
}}}

That is, the forall is used only to declare an assertion.

Expect: compile succeeds; run prints
{{{
this is fun
}}}

Actual: compiler error
{{{
Too few type arguments in generic type instance of struct thing with body 1
}}}

Workaround is to treat the generic type as if it had one type parameter, i.e.
{{{
forall ( dtype T | {void fun();} ) {

    struct thing ...
}}}

This workaround is
{{{
forall ( | {void fun();} ) {

    struct thing {};

    void ?{}( thing(float) & this ) {
        fun();
    }
}

void fun() {
    printf(""this is fun\n"");
}

int main() {
   thing(float) x;
}
}}}

Workaround Expected: compiler error
{{{
Too many type arguments in generic type instance of struct thing...
}}}

Workaround Actual: compile succeeds; run prints
{{{
this is fun
}}}

The cause (as originally captured in #222) of the issue is that the parser adds the extra parameter.  To see it:

{{{
forall (T & ) {
  forall ( | {void foo (T *); }) struct bar_t { T * fld; };
}
}}}

Actual prefix of compiling `-CFA -XCFA,-p,-Past`:
{{{
struct bar_t with body
... with parameters
  T: data type
  data type
  ...
}}}
Note that bar_t has two parameters (the two lines following `... with parameters`), the first named T, the second anonymous.

Expecting one parameter named T.
"	defect	new	minor	cfa-cc	1.0			
