diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-01-27 23:02:55 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-01-27 23:02:55 +0000 |
| commit | 31aacd5bf435224c7d8f9b19359175d3e6d25660 (patch) | |
| tree | ab9d62de198d9874e1afb7212ab3feb46fde4f01 /src | |
| parent | 92453369c5558feaaaa116fbc54968b087e1aeab (diff) | |
Fix parsing for block/if expression within if/for/etc. statementsv0.0.6
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_decl.c | 9 | ||||
| -rw-r--r-- | src/check_expr.c | 5 | ||||
| -rw-r--r-- | src/main.c | 2 | ||||
| -rw-r--r-- | src/parser.c | 13 | ||||
| -rw-r--r-- | src/types.c | 4 |
5 files changed, 22 insertions, 11 deletions
diff --git a/src/check_decl.c b/src/check_decl.c index 9fb786286..51655d445 100644 --- a/src/check_decl.c +++ b/src/check_decl.c @@ -302,10 +302,11 @@ void check_proc_lit(Checker *c, Entity *e, DeclInfo *d) { error_node(pd->body, "A procedure tagged as `#foreign` cannot have a body"); } - if (proc_type->Proc.calling_convention != ProcCC_Odin) { - error_node(d->proc_lit, "An internal procedure may only have the Odin calling convention"); - proc_type->Proc.calling_convention = ProcCC_Odin; - } + // TODO(bill): Is this the best option? What about passing to external shit?! + // if (proc_type->Proc.calling_convention != ProcCC_Odin) { + // error_node(d->proc_lit, "An internal procedure may only have the Odin calling convention"); + // proc_type->Proc.calling_convention = ProcCC_Odin; + // } d->scope = c->context.scope; diff --git a/src/check_expr.c b/src/check_expr.c index f6037beee..18c75ac9d 100644 --- a/src/check_expr.c +++ b/src/check_expr.c @@ -203,6 +203,11 @@ i64 check_distance_between_types(Checker *c, Operand *operand, Type *type) { } } + // if (is_type_proc(dst)) { + // if (are_types_identical(src, dst)) { + // return 1; + // } + // } if (is_type_any(dst)) { // NOTE(bill): Anything can cast to `Any` diff --git a/src/main.c b/src/main.c index 6e9afda3d..b35f399eb 100644 --- a/src/main.c +++ b/src/main.c @@ -240,7 +240,7 @@ int main(int argc, char **argv) { char lib_str_buf[1024] = {0}; for_array(i, ir_gen.module.foreign_library_paths) { String lib = ir_gen.module.foreign_library_paths.e[i]; - gb_printf_err("Linking lib: %.*s\n", LIT(lib)); + // gb_printf_err("Linking lib: %.*s\n", LIT(lib)); isize len = gb_snprintf(lib_str_buf, gb_size_of(lib_str_buf), " \"%.*s\"", LIT(lib)); lib_str = gb_string_appendc(lib_str, lib_str_buf); diff --git a/src/parser.c b/src/parser.c index 0a9b39ea9..eac6fbd68 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1827,11 +1827,15 @@ AstNode *parse_operand(AstFile *f, bool lhs) { } case Token_if: - if (lhs) goto error; - return parse_if_expr(f); + if (!lhs && f->expr_level >= 0) { + return parse_if_expr(f); + } + break; case Token_OpenBrace: - if (lhs) goto error; - return parse_block_expr(f); + if (!lhs && f->expr_level >= 0) { + return parse_block_expr(f); + } + break; default: { AstNode *type = parse_identifier_or_type(f); @@ -1846,7 +1850,6 @@ AstNode *parse_operand(AstFile *f, bool lhs) { } } -error: Token begin = f->curr_token; syntax_error(begin, "Expected an operand"); fix_advance_to_next_stmt(f); diff --git a/src/types.c b/src/types.c index c49ad4a42..7bb849fff 100644 --- a/src/types.c +++ b/src/types.c @@ -1194,7 +1194,9 @@ Selection lookup_field_with_selection(gbAllocator a, Type *type_, String field_n } else if (!is_type_union(type)) { for (isize i = 0; i < type->Record.field_count; i++) { Entity *f = type->Record.fields[i]; - GB_ASSERT(f->kind == Entity_Variable && f->flags & EntityFlag_Field); + if (f->kind != Entity_Variable || (f->flags & EntityFlag_Field) == 0) { + continue; + } String str = f->token.string; if (str_eq(field_name, str)) { selection_add_index(&sel, i); // HACK(bill): Leaky memory |