diff --git a/core/fmt.odin b/core/fmt.odin index 3ded6a6a6..2bdac8b89 100644 --- a/core/fmt.odin +++ b/core/fmt.odin @@ -559,7 +559,7 @@ proc _fmt_int(fi: ^FmtInfo, u: u128, base: int, is_signed: bool, bit_size: int, _pad(fi, s); } -let ( +var ( __DIGITS_LOWER = "0123456789abcdefx"; __DIGITS_UPPER = "0123456789ABCDEFX"; ) diff --git a/core/hash.odin b/core/hash.odin index 336a7bfde..68918551b 100644 --- a/core/hash.odin +++ b/core/hash.odin @@ -210,7 +210,7 @@ proc murmur64(data: []u8) -> u64 { } -let _crc32_table = [256]u32{ +var _crc32_table = [256]u32{ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, @@ -276,7 +276,7 @@ let _crc32_table = [256]u32{ 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, }; -let _crc64_table = [256]u64{ +var _crc64_table = [256]u64{ 0x0000000000000000, 0x42f0e1eba9ea3693, 0x85e1c3d753d46d26, 0xc711223cfa3e5bb5, 0x493366450e42ecdf, 0x0bc387aea7a8da4c, 0xccd2a5925d9681f9, 0x8e224479f47cb76a, 0x9266cc8a1c85d9be, 0xd0962d61b56fef2d, 0x17870f5d4f51b498, 0x5577eeb6e6bb820b, diff --git a/core/opengl.odin b/core/opengl.odin index 2be7b05cc..c0049ea9a 100644 --- a/core/opengl.odin +++ b/core/opengl.odin @@ -41,7 +41,7 @@ proc _string_data(s: string) -> ^u8 #inline { return &s[0]; } var _libgl = win32.load_library_a(_string_data("opengl32.dll\x00")); -proc get_proc_address(name: string) -> proc() #cc_c { +proc get_proc_address(name: string) -> rawptr { if name[len(name)-1] == 0 { name = name[0.. proc() #cc_c { if res == nil { res = win32.get_proc_address(_libgl, &name[0]); } - return res; + return rawptr(res); } var ( @@ -118,7 +118,7 @@ var ( proc init() { proc set_proc_address(p: rawptr, name: string) #inline { - var x = ^(proc() #cc_c)(p); + var x = ^rawptr(p); x^ = get_proc_address(name); } diff --git a/core/os_linux.odin b/core/os_linux.odin index 059e53a79..8944f4a9c 100644 --- a/core/os_linux.odin +++ b/core/os_linux.odin @@ -43,7 +43,7 @@ const ( ) // "Argv" arguments converted to Odin strings -let args = _alloc_command_line_arguments(); +var args = _alloc_command_line_arguments(); type _FileTime struct #ordered { seconds: i64, diff --git a/core/os_windows.odin b/core/os_windows.odin index f97af646f..70db3b350 100644 --- a/core/os_windows.odin +++ b/core/os_windows.odin @@ -54,7 +54,7 @@ const ( ) // "Argv" arguments converted to Odin strings -let args = _alloc_command_line_arguments(); +var args = _alloc_command_line_arguments(); proc open(path: string, mode: int = O_RDONLY, perm: u32 = 0) -> (Handle, Errno) { diff --git a/core/strconv.odin b/core/strconv.odin index 432526463..a887c7669 100644 --- a/core/strconv.odin +++ b/core/strconv.odin @@ -416,7 +416,7 @@ proc round_shortest(d: ^Decimal, mant: u64, exp: int, flt: ^Float_Info) { } const MAX_BASE = 32; -let digits = "0123456789abcdefghijklmnopqrstuvwxyz"; +var digits = "0123456789abcdefghijklmnopqrstuvwxyz"; proc is_integer_negative(u: u128, is_signed: bool, bit_size: int) -> (unsigned: u128, neg: bool) { diff --git a/core/utf8.odin b/core/utf8.odin index b6bd7fbab..821b0a8e9 100644 --- a/core/utf8.odin +++ b/core/utf8.odin @@ -32,7 +32,7 @@ const ( type AcceptRange struct { lo, hi: u8 } -let ( +var ( accept_ranges = [5]AcceptRange{ {0x80, 0xbf}, {0xa0, 0xbf}, diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 1fa0117ac..43d870261 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -5865,6 +5865,12 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t check_close_scope(c); return kind; } + + if (pl->body == NULL) { + error(node, "A procedure literal must have a body"); + return kind; + } + check_procedure_later(c, c->curr_ast_file, empty_token, decl, type, pl->body, pl->tags); } check_close_scope(c); diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 104733e67..0eac4936b 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1657,7 +1657,6 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) { if (decl->kind == AstNode_GenDecl) { switch (decl->GenDecl.token.kind) { case Token_var: - case Token_let: check_stmt(c, decl, flags); break; } @@ -1673,8 +1672,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) { for_array(i, gd->specs) { AstNode *spec = gd->specs[i]; switch (gd->token.kind) { - case Token_var: - case Token_let: { + case Token_var: { ast_node(vd, ValueSpec, spec); Entity **entities = gb_alloc_array(c->allocator, Entity *, vd->names.count); @@ -1699,7 +1697,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) { found = current_scope_lookup_entity(c->context.scope, str); } if (found == NULL) { - entity = make_entity_variable(c->allocator, c->context.scope, token, NULL, gd->token.kind == Token_let); + entity = make_entity_variable(c->allocator, c->context.scope, token, NULL, false); entity->identifier = name; AstNode *fl = c->context.curr_foreign_library; diff --git a/src/checker.cpp b/src/checker.cpp index 5576180a4..8d0ae001c 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -1635,8 +1635,7 @@ void check_collect_entities(Checker *c, Array nodes, bool is_file_sco check_arity_match(c, vs); } break; - case Token_var: - case Token_let: { + case Token_var: { if (!c->context.scope->is_file) { // NOTE(bill): local scope -> handle later and in order break; @@ -1671,7 +1670,7 @@ void check_collect_entities(Checker *c, Array nodes, bool is_file_sco error(name, "A declaration's name must be an identifier, got %.*s", LIT(ast_node_strings[name->kind])); continue; } - Entity *e = make_entity_variable(c->allocator, c->context.scope, name->Ident, NULL, gd->token.kind == Token_let); + Entity *e = make_entity_variable(c->allocator, c->context.scope, name->Ident, NULL, false); e->Variable.is_thread_local = (gd->flags & VarDeclFlag_thread_local) != 0; e->identifier = name; diff --git a/src/docs.cpp b/src/docs.cpp index 6478f490f..e0f27c62c 100644 --- a/src/docs.cpp +++ b/src/docs.cpp @@ -95,7 +95,6 @@ void print_declaration(AstNode *decl) { AstNode *spec = gd->specs[spec_index]; switch(gd->token.kind) { case Token_var: - case Token_let: break; case Token_const: break; diff --git a/src/ir.cpp b/src/ir.cpp index bd3dd8b36..d5fc33174 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -5947,8 +5947,7 @@ void ir_build_stmt_internal(irProcedure *proc, AstNode *node) { for_array(i, gd->specs) { AstNode *spec = gd->specs[i]; switch (gd->token.kind) { - case Token_var: - case Token_let: { + case Token_var: { ast_node(vd, ValueSpec, spec); irModule *m = proc->module; diff --git a/src/parser.cpp b/src/parser.cpp index 4f5c0ef07..f395b382a 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1760,7 +1760,6 @@ void fix_advance_to_next_stmt(AstFile *f) { case Token_var: case Token_const: - case Token_let: case Token_type: case Token_proc: case Token_foreign: @@ -1902,7 +1901,6 @@ void expect_semicolon(AstFile *f, AstNode *s) { if (s->kind == AstNode_GenDecl) { switch (s->GenDecl.token.kind) { case Token_var: - case Token_let: node_string = str_lit("variable declaration"); break; case Token_const: @@ -2292,7 +2290,9 @@ AstNode *parse_operand(AstFile *f, bool lhs) { AstNode *type = parse_proc_type(f, token, &link_name); u64 tags = type->ProcType.tags; - if (f->curr_token.kind == Token_OpenBrace) { + if (allow_token(f, Token_Undef)) { + return ast_proc_lit(f, type, NULL, tags, link_name); + } else if (f->curr_token.kind == Token_OpenBrace) { if ((tags & ProcTag_foreign) != 0) { syntax_error(token, "A procedure tagged as `#foreign` cannot have a body"); } @@ -2749,7 +2749,9 @@ AstNode *parse_proc_decl(AstFile *f) { f->allow_gen_proc_type = prev_allow_gen_proc_type; - if (f->curr_token.kind == Token_OpenBrace) { + if (allow_token(f, Token_Undef)) { + body = NULL; + } else if (f->curr_token.kind == Token_OpenBrace) { if ((tags & ProcTag_foreign) != 0) { syntax_error(token, "A procedure tagged as `#foreign` cannot have a body"); } @@ -3002,7 +3004,6 @@ void parse_foreign_block_decl(AstFile *f, Array *decls) { case AstNode_GenDecl: switch (decl->GenDecl.token.kind) { case Token_var: - case Token_let: array_add(decls, decl); return; } @@ -3019,7 +3020,6 @@ AstNode *parse_decl(AstFile *f) { switch (f->curr_token.kind) { case Token_var: case Token_const: - case Token_let: func = parse_value_spec; break; @@ -3088,7 +3088,6 @@ AstNode *parse_simple_stmt(AstFile *f, StmtAllowFlag flags) { switch (f->curr_token.kind) { case Token_var: case Token_const: - case Token_let: return parse_decl(f); } @@ -4247,7 +4246,6 @@ AstNode *parse_stmt(AstFile *f) { case Token_var: case Token_const: - case Token_let: case Token_proc: case Token_type: case Token_import: @@ -4287,8 +4285,7 @@ AstNode *parse_stmt(AstFile *f) { // TODO(bill): Make using statements better Token token = expect_token(f, Token_using); AstNode *decl = NULL; - if (f->curr_token.kind == Token_var || - f->curr_token.kind == Token_let) { + if (f->curr_token.kind == Token_var) { decl = parse_decl(f); expect_semicolon(f, decl); } else { @@ -4307,8 +4304,7 @@ AstNode *parse_stmt(AstFile *f) { if (decl != NULL && decl->kind == AstNode_GenDecl) { - if (decl->GenDecl.token.kind != Token_var && - decl->GenDecl.token.kind != Token_let) { + if (decl->GenDecl.token.kind != Token_var) { syntax_error(token, "`using` may only be applied to variable declarations"); return decl; } @@ -4384,8 +4380,7 @@ AstNode *parse_stmt(AstFile *f) { AstNode *s = parse_stmt(f); if (s->kind == AstNode_GenDecl) { - if (s->GenDecl.token.kind != Token_var && - s->GenDecl.token.kind != Token_let) { + if (s->GenDecl.token.kind != Token_var) { syntax_error(token, "`thread_local` may only be applied to variable declarations"); } if (f->curr_proc != NULL) { diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index c7c53a47e..61d1eccc3 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -84,7 +84,6 @@ TOKEN_KIND(Token__OperatorEnd, "_OperatorEnd"), \ \ TOKEN_KIND(Token__KeywordBegin, "_KeywordBegin"), \ TOKEN_KIND(Token_var, "var"), \ - TOKEN_KIND(Token_let, "let"), \ TOKEN_KIND(Token_const, "const"), \ TOKEN_KIND(Token_type, "type"), \ TOKEN_KIND(Token_import, "import"), \