mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-25 23:14:59 -07:00
Remove let
This commit is contained in:
@@ -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);
|
||||
|
||||
+2
-4
@@ -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;
|
||||
|
||||
+2
-3
@@ -1635,8 +1635,7 @@ void check_collect_entities(Checker *c, Array<AstNode *> 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<AstNode *> 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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-2
@@ -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;
|
||||
|
||||
+9
-14
@@ -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<AstNode *> *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) {
|
||||
|
||||
@@ -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"), \
|
||||
|
||||
Reference in New Issue
Block a user