Skip to content

Commit 8017e2f

Browse files
committed
fixed: misc bugs
1 parent 8f93988 commit 8017e2f

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

compiler/src/parser.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static void parse_polymorphic_variable(OnyxParser* parser, AstType***
6666
static AstType* parse_type(OnyxParser* parser);
6767
static AstTypeOf* parse_typeof(OnyxParser* parser);
6868
static AstStructType* parse_struct(OnyxParser* parser);
69+
static AstUnionType* parse_union(OnyxParser* parser);
6970
static AstInterface* parse_interface(OnyxParser* parser);
7071
static AstConstraint* parse_constraint(OnyxParser* parser);
7172
static void parse_constraints(OnyxParser* parser, ConstraintContext *constraints);
@@ -2496,6 +2497,14 @@ static AstType* parse_type(OnyxParser* parser) {
24962497
break;
24972498
}
24982499

2500+
case Token_Type_Keyword_Union: {
2501+
AstUnionType* u_node = parse_union(parser);
2502+
*next_insertion = (AstType *) u_node;
2503+
next_insertion = NULL;
2504+
type_can_be_done = 1;
2505+
break;
2506+
}
2507+
24992508
//
25002509
// I don't think any of these cases are necesary any more?
25012510
case Token_Type_Literal_Integer:

compiler/src/types.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ static Type* type_build_from_ast_inner(Context *context, AstType* type_node, b32
776776

777777
AstEnumType* tag_enum_node = onyx_ast_node_new(context->ast_alloc, sizeof(AstEnumType), Ast_Kind_Enum_Type);
778778
tag_enum_node->token = union_->token;
779-
tag_enum_node->name = bh_aprintf(context->ast_alloc, "%s.tag_enum", union_->name);
779+
tag_enum_node->name = bh_aprintf(context->ast_alloc, "%s.tag_enum", type_get_name(context, (Type *) u_type));
780780
tag_enum_node->backing_type = type_build_from_ast(context, union_->tag_backing_type);
781781
bh_arr_new(context->ast_alloc, tag_enum_node->values, bh_arr_length(union_->variants));
782782

compiler/src/wasm_emit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3615,7 +3615,7 @@ EMIT_FUNC(expression, AstTyped* expr) {
36153615
case Ast_Kind_Code_Block: {
36163616
// Like above, this error message should be moved to checking, but
36173617
// this is the best place to do it right now.
3618-
ONYX_ERROR(expr->token->pos, Error_Critical, "'#quote' blocks are only to be used at compile-time. Using them as a runtime value is not allowed.");
3618+
ONYX_ERROR(expr->token->pos, Error_Critical, "Code blocks are only to be used at compile-time with '#unquote'. Using them as a runtime value is not allowed.");
36193619
break;
36203620
}
36213621

0 commit comments

Comments
 (0)