﻿id	summary	reporter	owner	description	type	status	priority	component	version	resolution	keywords	cc
7	CFA Assertion Error: CodeGenerator visits TypeExpr in trait/genaric type	ajbeach		"So I was trying to create a new stack with an implicate error handler and it still is not working. I am getting a failure in code generation. It appears to be trying to generate the code for the trait I created.

A trimmed down version of the code, which still generates the same error, is included:
{{{
#include <stdlib.hfa>
extern ""C"" {
#include <stdbool.h>
}

// (Bug 1 unresolved as of this test.)
forall(otype T)
struct stack_node;

forall(otype T)
struct stack_node {
    stack_node(T) * next;
    T item;
};

forall(otype T)
struct stack {
    stack_node(T) * head;
};

trait stack_errors(otype T) {
    T emptyStackHandler (stack(T) * this);
};

forall(otype T | stack_errors(T))
T pop (stack(T) * this) {
    return (T){};
}

int emptyStackHandler (stack(int) * this) {
    return 0;
}

int main (int argc, char * argv[]) {
    stack(int) stackOfInts;
    pop(&stackOfInts);
    return 0;
}
}}}
I did a trace with gdb and it seems to be happening at line 22, which is the body of the trait stack_errors. Here is also a copy of the error message (minus stack trace).
{{{
*CFA assertion error* from program ""cfa-cpp"" in ""virtual void CodeGen::CodeGenerator::visit(TypeExpr*)"" at line 733 in file ""CodeGen/CodeGenerator.cc"": TypeExpr should not reach code generation.
}}}"	defect	new	minor	cfa-cc	1.0			a3moss
