}
array_map :: proc (arr: [..] $T, f: proc (T) -> T) {
- test2();
-
foo := #solidify math.max { T = T };
is := (#type InternalStruct(T)).{ foo = foo(6, 2) };
printf("%i\n", is.foo);
for ^v: arr do *v = f(*v);
- test2 :: proc () {
- test();
- println("WORLD!!!!");
- }
+ {
+ test2();
+
+ test2 :: proc () {
+ test();
+
+ is : InternalStruct([] u32);
+
+ println("WORLD!!!!");
+ }
- test :: proc () {
- println("HELLO!!!");
+ test :: proc () {
+ println("HELLO!!!");
+ }
}
InternalStruct :: struct ($SOMETHING) {
Scope* scope = parser->file_scope;
if (!bh_arr_is_empty(parser->block_stack)) {
- Scope* binding_scope = parser->block_stack[bh_arr_length(parser->block_stack) - 1]->binding_scope;
-
- if (binding_scope != NULL)
- scope = binding_scope;
+ scope = parser->block_stack[bh_arr_length(parser->block_stack) - 1]->binding_scope;
+ assert(scope != NULL);
}
bh_arr_push(parser->results.nodes_to_process, ((NodeToProcess) {
if (parser->curr->type == ':') {
AstBlock* current_block = parser->block_stack[bh_arr_length(parser->block_stack) - 1];
- if (current_block->binding_scope == NULL) {
- // TODO: Check this is right. I suspect it may allow more things to be
- // valid than I want it to.
-
- Scope* parent_scope = parser->file_scope;
- if (bh_arr_length(parser->block_stack) > 1) {
- parent_scope = parser->block_stack[bh_arr_length(parser->block_stack) - 2]->binding_scope;
- }
-
- current_block->binding_scope = scope_create(parser->allocator, parent_scope, current_block->token->pos);
- }
+ assert(current_block->binding_scope != NULL);
AstBinding* binding = parse_top_level_binding(parser, symbol);
symbol_introduce(current_block->binding_scope, symbol, binding->node);
AstBlock* block = make_node(AstBlock, Ast_Kind_Block);
bh_arr_new(global_heap_allocator, block->allocate_exprs, 4);
+ {
+ Scope* parent_scope = parser->file_scope;
+ if (!bh_arr_is_empty(parser->block_stack))
+ parent_scope = bh_arr_last(parser->block_stack)->binding_scope;
+ block->binding_scope = scope_create(parser->allocator, parent_scope, parser->curr->pos);
+ }
+
bh_arr_push(parser->block_stack, block);
// NOTE: --- is for an empty block