Skip to content

Commit 9cbb7ab

Browse files
committed
fixed: compilation
1 parent faad29d commit 9cbb7ab

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

compiler/src/astnodes.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,6 +1970,7 @@ AstCall * create_implicit_for_expansion_call(Context *context, AstFor *fornode)
19701970
body_code_block->token = fornode->token;
19711971
body_code_block->type_node = context->builtins.code_type;
19721972
body_code_block->code = (AstNode *) fornode->stmt;
1973+
body_code_block->enclosing_scope = context->checker.current_scope;
19731974
((AstBlock *) body_code_block->code)->rules = Block_Rule_Code_Block;
19741975

19751976
bh_arr_new(context->ast_alloc, body_code_block->binding_symbols, bh_arr_length(fornode->indexing_variables));
@@ -1986,13 +1987,11 @@ AstCall * create_implicit_for_expansion_call(Context *context, AstFor *fornode)
19861987

19871988
AstNumLit *flag_node = make_int_literal(context, flags);
19881989
flag_node->type_node = context->builtins.for_expansion_flag_type;
1989-
// flag_node->type = type_build_from_ast(context, context->builtins.for_expansion_flag_type);
1990-
// assert(flag_node->type);
19911990

19921991
// Arguments are:
19931992
// Iterator
1994-
// Code block with 2 inputs (value, index)
19951993
// Flags
1994+
// Code block with 2 inputs (value, index)
19961995
bh_arr_push(call->args.values, (AstTyped *) make_argument(context, (AstTyped *) fornode->iter));
19971996
bh_arr_push(call->args.values, (AstTyped *) make_argument(context, (AstTyped *) flag_node));
19981997
bh_arr_push(call->args.values, (AstTyped *) make_argument(context, (AstTyped *) body_code_block));

compiler/src/checker.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,16 +3128,22 @@ CHECK_FUNC(expression, AstTyped** pexpr) {
31283128
retval = check_insert_directive(context, (AstDirectiveInsert **) pexpr, 1);
31293129
break;
31303130

3131-
case Ast_Kind_Code_Block:
3132-
expr->flags |= Ast_Flag_Comptime;
3133-
((AstCodeBlock *) expr)->enclosing_scope = context->checker.current_scope;
3131+
case Ast_Kind_Code_Block: {
3132+
AstCodeBlock *block = (void *) expr;
3133+
31343134
fill_in_type(context, expr);
3135-
bh_arr_each(CodeBlockBindingSymbol, sym, ((AstCodeBlock *) expr)->binding_symbols) {
3135+
block->flags |= Ast_Flag_Comptime;
3136+
3137+
if (!block->enclosing_scope)
3138+
block->enclosing_scope = context->checker.current_scope;
3139+
3140+
bh_arr_each(CodeBlockBindingSymbol, sym, block->binding_symbols) {
31363141
if (sym->type_node) {
31373142
CHECK(expression, (AstTyped **) &sym->type_node);
31383143
}
31393144
}
31403145
break;
3146+
}
31413147

31423148
case Ast_Kind_Do_Block: {
31433149
Scope* old_current_scope = context->checker.current_scope;

compiler/src/clone.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ static inline i32 ast_kind_to_size(AstNode* node) {
118118
case Ast_Kind_Union_Type: return sizeof(AstUnionType);
119119
case Ast_Kind_Union_Variant: return sizeof(AstUnionVariant);
120120
case Ast_Kind_Procedural_Expansion: return sizeof(AstProceduralExpansion);
121+
case Ast_Kind_Code_Block: return sizeof(AstCodeBlock);
121122

122123
default: break;
123124
}

0 commit comments

Comments
 (0)