int main() { check_union(); check_union_member(); return 0; }
static bool check_type(compile_t* c, LLVMValueRef ptr, LLVMValueRef desc, ast_t* pattern_type, LLVMBasicBlockRef next_block) { switch(ast_id(pattern_type)) { case TK_NOMINAL: // We are trying to capture the match expression as a nominal. return check_nominal(c, desc, pattern_type, next_block); case TK_TUPLETYPE: // We are trying to capture the match expression as a tuple. return check_tuple(c, ptr, desc, pattern_type, next_block); case TK_UNIONTYPE: // We are trying to capture the match expression as a union. return check_union(c, ptr, desc, pattern_type, next_block); case TK_ISECTTYPE: // We are trying to capture the match expression as an intersection. return check_isect(c, ptr, desc, pattern_type, next_block); case TK_ARROW: // We are trying to capture the match expression as a viewpoint type, so // try again with the right-hand side of the arrow. return check_type(c, ptr, desc, ast_childidx(pattern_type, 1), next_block); default: {} } assert(0); return false; }