In error messages, remove with '; Fix error messages for switch`

This commit is contained in:
gingerBill
2017-11-12 19:00:48 +00:00
parent 5ce6555721
commit dffa791607
9 changed files with 547 additions and 547 deletions

View File

@@ -1,7 +1,7 @@
bool check_is_terminating(AstNode *node);
void check_stmt (Checker *c, AstNode *node, u32 flags);
// NOTE(bill): `content_name` is for debugging and error messages
// NOTE(bill): 'content_name' is for debugging and error messages
Type *check_init_variable(Checker *c, Entity *e, Operand *operand, String context_name) {
if (operand->mode == Addressing_Invalid ||
operand->type == t_invalid ||
@@ -13,7 +13,7 @@ Type *check_init_variable(Checker *c, Entity *e, Operand *operand, String contex
// TODO(bill): is this a good enough error message?
// TODO(bill): Actually allow built in procedures to be passed around and thus be created on use
error(operand->expr,
"Cannot assign built-in procedure `%s` in %.*s",
"Cannot assign built-in procedure '%s' in %.*s",
expr_str,
LIT(context_name));
@@ -25,7 +25,7 @@ Type *check_init_variable(Checker *c, Entity *e, Operand *operand, String contex
if (operand->mode == Addressing_Overload) {
if (e->type == nullptr) {
error(operand->expr, "Cannot determine type from overloaded procedure `%.*s`", LIT(operand->overload_entities[0]->token.string));
error(operand->expr, "Cannot determine type from overloaded procedure '%.*s'", LIT(operand->overload_entities[0]->token.string));
} else {
check_assignment(c, operand, e->type, str_lit("variable assignment"));
if (operand->mode != Addressing_Type) {
@@ -62,13 +62,13 @@ Type *check_init_variable(Checker *c, Entity *e, Operand *operand, String contex
if (is_type_polymorphic(t)) {
gbString str = type_to_string(t);
defer (gb_string_free(str));
error(e->token, "Invalid use of a polymorphic type `%s` in %.*s", str, LIT(context_name));
error(e->token, "Invalid use of a polymorphic type '%s' in %.*s", str, LIT(context_name));
e->type = t_invalid;
return nullptr;
} else if (is_type_empty_union(t)) {
gbString str = type_to_string(t);
defer (gb_string_free(str));
error(e->token, "An empty union `%s` cannot be instantiated in %.*s", str, LIT(context_name));
error(e->token, "An empty union '%s' cannot be instantiated in %.*s", str, LIT(context_name));
e->type = t_invalid;
return nullptr;
}
@@ -122,7 +122,7 @@ void check_init_variables(Checker *c, Entity **lhs, isize lhs_count, Array<AstNo
}
}
if (rhs_count > 0 && lhs_count != rhs_count) {
error(lhs[0]->token, "Assignment count mismatch `%td` = `%td`", lhs_count, rhs_count);
error(lhs[0]->token, "Assignment count mismatch '%td' = '%td'", lhs_count, rhs_count);
}
}
@@ -139,7 +139,7 @@ void check_init_constant(Checker *c, Entity *e, Operand *operand) {
if (operand->mode != Addressing_Constant) {
// TODO(bill): better error
gbString str = expr_to_string(operand->expr);
error(operand->expr, "`%s` is not a constant", str);
error(operand->expr, "'%s' is not a constant", str);
gb_string_free(str);
if (e->type == nullptr) {
e->type = t_invalid;
@@ -148,7 +148,7 @@ void check_init_constant(Checker *c, Entity *e, Operand *operand) {
}
if (!is_type_constant_type(operand->type)) {
gbString type_str = type_to_string(operand->type);
error(operand->expr, "Invalid constant type: `%s`", type_str);
error(operand->expr, "Invalid constant type: '%s'", type_str);
gb_string_free(type_str);
if (e->type == nullptr) {
e->type = t_invalid;
@@ -211,7 +211,7 @@ void check_type_decl(Checker *c, Entity *e, AstNode *type_expr, Type *def, bool
e->TypeName.is_type_alias = true;
} else {
gbString str = type_to_string(bt);
error(type_expr, "Type alias declaration with a non-named type `%s`", str);
error(type_expr, "Type alias declaration with a non-named type '%s'", str);
gb_string_free(str);
}
}
@@ -231,7 +231,7 @@ void check_const_decl(Checker *c, Entity *e, AstNode *type_expr, AstNode *init,
Type *t = check_type(c, type_expr);
if (!is_type_constant_type(t)) {
gbString str = type_to_string(t);
error(type_expr, "Invalid constant type `%s`", str);
error(type_expr, "Invalid constant type '%s'", str);
gb_string_free(str);
e->type = t_invalid;
return;
@@ -324,7 +324,7 @@ void check_const_decl(Checker *c, Entity *e, AstNode *type_expr, AstNode *init,
if (operand.mode == Addressing_Invalid ||
base_type(operand.type) == t_invalid) {
gbString str = expr_to_string(init);
error(e->token, "Invalid declaration type `%s`", str);
error(e->token, "Invalid declaration type '%s'", str);
gb_string_free(str);
}
@@ -415,12 +415,12 @@ void init_entity_foreign_library(Checker *c, Entity *e) {
Entity *found = scope_lookup_entity(c->context.scope, name);
if (found == nullptr) {
if (is_blank_ident(name)) {
error(ident, "`_` cannot be used as a value type");
error(ident, "'_' cannot be used as a value type");
} else {
error(ident, "Undeclared name: %.*s", LIT(name));
}
} else if (found->kind != Entity_LibraryName) {
error(ident, "`%.*s` cannot be used as a library name", LIT(name));
error(ident, "'%.*s' cannot be used as a library name", LIT(name));
} else {
// TODO(bill): Extra stuff to do with library names?
*foreign_library = found;
@@ -432,7 +432,7 @@ void init_entity_foreign_library(Checker *c, Entity *e) {
String handle_link_name(Checker *c, Token token, String link_name, String link_prefix) {
if (link_prefix.len > 0) {
if (link_name.len > 0) {
error(token, "`link_name` and `link_prefix` cannot be used together");
error(token, "'link_name' and 'link_prefix' cannot be used together");
} else {
isize len = link_prefix.len + token.string.len;
u8 *name = gb_alloc_array(c->allocator, u8, len+1);
@@ -491,17 +491,17 @@ void check_proc_decl(Checker *c, Entity *e, DeclInfo *d) {
if (pt->param_count != 0 ||
pt->result_count != 0) {
gbString str = type_to_string(proc_type);
error(e->token, "Procedure type of `main` was expected to be `proc()`, got %s", str);
error(e->token, "Procedure type of 'main' was expected to be 'proc()', got %s", str);
gb_string_free(str);
}
if (pt->calling_convention != ProcCC_Odin &&
pt->calling_convention != ProcCC_Contextless) {
error(e->token, "Procedure `main` cannot have a custom calling convention");
error(e->token, "Procedure 'main' cannot have a custom calling convention");
}
pt->calling_convention = ProcCC_Contextless;
if (d->scope->is_init) {
if (c->info.entry_point != nullptr) {
error(e->token, "Redeclaration of the entry pointer procedure `main`");
error(e->token, "Redeclaration of the entry pointer procedure 'main'");
} else {
c->info.entry_point = e;
}
@@ -509,7 +509,7 @@ void check_proc_decl(Checker *c, Entity *e, DeclInfo *d) {
}
if (is_foreign && is_export) {
error(pl->type, "A foreign procedure cannot have an `export` tag");
error(pl->type, "A foreign procedure cannot have an 'export' tag");
}
if (pt->is_polymorphic) {
@@ -528,7 +528,7 @@ void check_proc_decl(Checker *c, Entity *e, DeclInfo *d) {
error(pl->body, "A foreign procedure cannot have a body");
}
if (proc_type->Proc.c_vararg) {
error(pl->body, "A procedure with a `#c_vararg` field cannot have a body and must be foreign");
error(pl->body, "A procedure with a '#c_vararg' field cannot have a body and must be foreign");
}
d->scope = c->context.scope;
@@ -546,7 +546,7 @@ void check_proc_decl(Checker *c, Entity *e, DeclInfo *d) {
}
if (pt->result_count == 0 && is_require_results) {
error(pl->type, "`#require_results` is not needed on a procedure with no results");
error(pl->type, "'#require_results' is not needed on a procedure with no results");
} else {
pt->require_results = is_require_results;
}
@@ -576,18 +576,18 @@ void check_proc_decl(Checker *c, Entity *e, DeclInfo *d) {
if (is_type_proc(this_type) && is_type_proc(other_type)) {
if (!are_signatures_similar_enough(this_type, other_type)) {
error(d->proc_lit,
"Redeclaration of foreign procedure `%.*s` with different type signatures\n"
"Redeclaration of foreign procedure '%.*s' with different type signatures\n"
"\tat %.*s(%td:%td)",
LIT(name), LIT(pos.file), pos.line, pos.column);
}
} else if (!are_types_identical(this_type, other_type)) {
error(d->proc_lit,
"Foreign entity `%.*s` previously declared elsewhere with a different type\n"
"Foreign entity '%.*s' previously declared elsewhere with a different type\n"
"\tat %.*s(%td:%td)",
LIT(name), LIT(pos.file), pos.line, pos.column);
}
} else if (name == "main") {
error(d->proc_lit, "The link name `main` is reserved for internal use");
error(d->proc_lit, "The link name 'main' is reserved for internal use");
} else {
map_set(fp, key, e);
}
@@ -605,11 +605,11 @@ void check_proc_decl(Checker *c, Entity *e, DeclInfo *d) {
TokenPos pos = f->token.pos;
// TODO(bill): Better error message?
error(d->proc_lit,
"Non unique linking name for procedure `%.*s`\n"
"Non unique linking name for procedure '%.*s'\n"
"\tother at %.*s(%td:%td)",
LIT(name), LIT(pos.file), pos.line, pos.column);
} else if (name == "main") {
error(d->proc_lit, "The link name `main` is reserved for internal use");
error(d->proc_lit, "The link name 'main' is reserved for internal use");
} else {
map_set(fp, key, e);
}
@@ -647,12 +647,12 @@ void check_var_decl(Checker *c, Entity *e, Entity **entities, isize entity_count
if (is_type_polymorphic(base_type(e->type))) {
gbString str = type_to_string(e->type);
defer (gb_string_free(str));
error(e->token, "Invalid use of a polymorphic type `%s` in %.*s", str, LIT(context_name));
error(e->token, "Invalid use of a polymorphic type '%s' in %.*s", str, LIT(context_name));
e->type = t_invalid;
} else if (is_type_empty_union(e->type)) {
gbString str = type_to_string(e->type);
defer (gb_string_free(str));
error(e->token, "An empty union `%s` cannot be instantiated in %.*s", str, LIT(context_name));
error(e->token, "An empty union '%s' cannot be instantiated in %.*s", str, LIT(context_name));
e->type = t_invalid;
}
}
@@ -683,7 +683,7 @@ void check_var_decl(Checker *c, Entity *e, Entity **entities, isize entity_count
Type *other_type = base_type(f->type);
if (!are_types_identical(this_type, other_type)) {
error(e->token,
"Foreign entity `%.*s` previously declared elsewhere with a different type\n"
"Foreign entity '%.*s' previously declared elsewhere with a different type\n"
"\tat %.*s(%td:%td)",
LIT(name), LIT(pos.file), pos.line, pos.column);
}
@@ -720,7 +720,7 @@ void check_entity_decl(Checker *c, Entity *e, DeclInfo *d, Type *named_type) {
e->type = t_invalid;
set_base_type(named_type, t_invalid);
return;
// GB_PANIC("`%.*s` should been declared!", LIT(e->token.string));
// GB_PANIC("'%.*s' should been declared!", LIT(e->token.string));
}
}
@@ -801,13 +801,13 @@ void check_proc_body(Checker *c, Token token, DeclInfo *decl, Type *type, AstNod
uvar->Variable.is_immutable = is_immutable;
Entity *prev = scope_insert_entity(c->context.scope, uvar);
if (prev != nullptr) {
error(e->token, "Namespace collision while `using` `%.*s` of: %.*s", LIT(name), LIT(prev->token.string));
error(e->token, "Namespace collision while 'using' '%.*s' of: %.*s", LIT(name), LIT(prev->token.string));
break;
}
}
}
} else {
error(e->token, "`using` can only be applied to variables of type struct");
error(e->token, "'using' can only be applied to variables of type struct");
break;
}
}
@@ -820,7 +820,7 @@ void check_proc_body(Checker *c, Token token, DeclInfo *decl, Type *type, AstNod
if (type->Proc.result_count > 0) {
if (!check_is_terminating(body)) {
if (token.kind == Token_Ident) {
error(bs->close, "Missing return statement at the end of the procedure `%.*s`", LIT(token.string));
error(bs->close, "Missing return statement at the end of the procedure '%.*s'", LIT(token.string));
} else {
error(bs->close, "Missing return statement at the end of the procedure");
}

File diff suppressed because it is too large Load Diff

View File

@@ -30,11 +30,11 @@ void check_stmt_list(Checker *c, Array<AstNode *> stmts, u32 flags) {
if (i+1 < max) {
switch (n->kind) {
case AstNode_ReturnStmt:
error(n, "Statements after this `return` are never executed");
error(n, "Statements after this 'return' are never executed");
break;
case AstNode_BranchStmt:
error(n, "Statements after this `%.*s` are never executed", LIT(n->BranchStmt.token.string));
error(n, "Statements after this '%.*s' are never executed", LIT(n->BranchStmt.token.string));
break;
}
}
@@ -93,9 +93,9 @@ bool check_has_break(AstNode *stmt, bool implicit) {
// NOTE(bill): The last expression has to be a `return` statement
// NOTE(bill): The last expression has to be a 'return' statement
// TODO(bill): This is a mild hack and should be probably handled properly
// TODO(bill): Warn/err against code after `return` that it won't be executed
// TODO(bill): Warn/err against code after 'return' that it won't be executed
bool check_is_terminating(AstNode *node) {
switch (node->kind) {
case_ast_node(rs, ReturnStmt, node);
@@ -186,10 +186,10 @@ Type *check_assignment_variable(Checker *c, Operand *lhs, Operand *rhs) {
AstNode *node = unparen_expr(lhs->expr);
// NOTE(bill): Ignore assignments to `_`
// NOTE(bill): Ignore assignments to '_'
if (is_blank_ident(node)) {
add_entity_definition(&c->info, node, nullptr);
check_assignment(c, rhs, nullptr, str_lit("assignment to `_` identifier"));
check_assignment(c, rhs, nullptr, str_lit("assignment to '_' identifier"));
if (rhs->mode == Addressing_Invalid) {
return nullptr;
}
@@ -280,7 +280,7 @@ Type *check_assignment_variable(Checker *c, Operand *lhs, Operand *rhs) {
}
gbString lhs_expr = expr_to_string(lhs->expr);
gbString rhs_expr = expr_to_string(rhs->expr);
error(rhs->expr, "Cannot assign `%s` to bit field `%s`", rhs_expr, lhs_expr);
error(rhs->expr, "Cannot assign '%s' to bit field '%s'", rhs_expr, lhs_expr);
gb_string_free(rhs_expr);
gb_string_free(lhs_expr);
return nullptr;
@@ -297,7 +297,7 @@ Type *check_assignment_variable(Checker *c, Operand *lhs, Operand *rhs) {
if (tav.mode != Addressing_Variable) {
if (!is_type_pointer(tav.type)) {
gbString str = expr_to_string(lhs->expr);
error(lhs->expr, "Cannot assign to the value of a map `%s`", str);
error(lhs->expr, "Cannot assign to the value of a map '%s'", str);
gb_string_free(str);
return nullptr;
}
@@ -315,7 +315,7 @@ Type *check_assignment_variable(Checker *c, Operand *lhs, Operand *rhs) {
check_expr(c, &op_c, se->expr);
if (op_c.mode == Addressing_MapIndex) {
gbString str = expr_to_string(lhs->expr);
error(lhs->expr, "Cannot assign to struct field `%s` in map", str);
error(lhs->expr, "Cannot assign to struct field '%s' in map", str);
gb_string_free(str);
return nullptr;
}
@@ -323,9 +323,9 @@ Type *check_assignment_variable(Checker *c, Operand *lhs, Operand *rhs) {
gbString str = expr_to_string(lhs->expr);
if (lhs->mode == Addressing_Immutable) {
error(lhs->expr, "Cannot assign to an immutable: `%s`", str);
error(lhs->expr, "Cannot assign to an immutable: '%s'", str);
} else {
error(lhs->expr, "Cannot assign to `%s`", str);
error(lhs->expr, "Cannot assign to '%s'", str);
}
gb_string_free(str);
@@ -341,21 +341,21 @@ Type *check_assignment_variable(Checker *c, Operand *lhs, Operand *rhs) {
return rhs->type;
}
enum MatchTypeKind {
MatchType_Invalid,
MatchType_Union,
MatchType_Any,
enum SwitchTypeKind {
SwitchType_Invalid,
SwitchType_Union,
SwitchType_Any,
};
MatchTypeKind check_valid_type_match_type(Type *type) {
SwitchTypeKind check_valid_type_switch_type(Type *type) {
type = type_deref(type);
if (is_type_union(type)) {
return MatchType_Union;
return SwitchType_Union;
}
if (is_type_any(type)) {
return MatchType_Any;
return SwitchType_Any;
}
return MatchType_Invalid;
return SwitchType_Invalid;
}
void check_stmt_internal(Checker *c, AstNode *node, u32 flags);
@@ -394,11 +394,11 @@ void check_when_stmt(Checker *c, AstNodeWhenStmt *ws, u32 flags) {
Operand operand = {Addressing_Invalid};
check_expr(c, &operand, ws->cond);
if (operand.mode != Addressing_Constant || !is_type_boolean(operand.type)) {
error(ws->cond, "Non-constant boolean `when` condition");
error(ws->cond, "Non-constant boolean 'when' condition");
return;
}
if (ws->body == nullptr || ws->body->kind != AstNode_BlockStmt) {
error(ws->cond, "Invalid body for `when` statement");
error(ws->cond, "Invalid body for 'when' statement");
return;
}
if (operand.value.kind == ExactValue_Bool &&
@@ -413,7 +413,7 @@ void check_when_stmt(Checker *c, AstNodeWhenStmt *ws, u32 flags) {
check_when_stmt(c, &ws->else_stmt->WhenStmt, flags);
break;
default:
error(ws->else_stmt, "Invalid `else` statement in `when` statement");
error(ws->else_stmt, "Invalid 'else' statement in 'when' statement");
break;
}
}
@@ -445,7 +445,7 @@ void check_label(Checker *c, AstNode *label) {
for_array(i, c->context.decl->labels) {
BlockLabel bl = c->context.decl->labels[i];
if (bl.name == name) {
error(label, "Duplicate label with the name `%.*s`", LIT(name));
error(label, "Duplicate label with the name '%.*s'", LIT(name));
ok = false;
break;
}
@@ -461,10 +461,10 @@ void check_label(Checker *c, AstNode *label) {
}
}
// Returns `true` for `continue`, `false` for `return`
// Returns 'true' for 'continue', 'false' for 'return'
bool check_using_stmt_entity(Checker *c, AstNodeUsingStmt *us, AstNode *expr, bool is_selector, Entity *e) {
if (e == nullptr) {
error(us->token, "`using` applied to an unknown entity");
error(us->token, "'using' applied to an unknown entity");
return true;
}
@@ -481,14 +481,14 @@ bool check_using_stmt_entity(Checker *c, AstNodeUsingStmt *us, AstNode *expr, bo
Entity *found = scope_insert_entity(c->context.scope, f);
if (found != nullptr) {
gbString expr_str = expr_to_string(expr);
error(us->token, "Namespace collision while `using` `%s` of: %.*s", expr_str, LIT(found->token.string));
error(us->token, "Namespace collision while 'using' '%s' of: %.*s", expr_str, LIT(found->token.string));
gb_string_free(expr_str);
return false;
}
f->using_parent = e;
}
} else {
error(us->token, "`using` can be only applied to enum type entities");
error(us->token, "'using' can be only applied to enum type entities");
}
break;
@@ -504,7 +504,7 @@ bool check_using_stmt_entity(Checker *c, AstNodeUsingStmt *us, AstNode *expr, bo
if (found != nullptr) {
gbString expr_str = expr_to_string(expr);
error(us->token,
"Namespace collision while `using` `%s` of: %.*s\n"
"Namespace collision while 'using' '%s' of: %.*s\n"
"\tat %.*s(%td:%td)\n"
"\tat %.*s(%td:%td)",
expr_str, LIT(found->token.string),
@@ -534,14 +534,14 @@ bool check_using_stmt_entity(Checker *c, AstNodeUsingStmt *us, AstNode *expr, bo
Entity *prev = scope_insert_entity(c->context.scope, uvar);
if (prev != nullptr) {
gbString expr_str = expr_to_string(expr);
error(us->token, "Namespace collision while `using` `%s` of: %.*s", expr_str, LIT(prev->token.string));
error(us->token, "Namespace collision while 'using' '%s' of: %.*s", expr_str, LIT(prev->token.string));
gb_string_free(expr_str);
return false;
}
}
}
} else {
error(us->token, "`using` can only be applied to variables of type struct or raw_union");
error(us->token, "'using' can only be applied to variables of type struct or raw_union");
return false;
}
@@ -549,28 +549,28 @@ bool check_using_stmt_entity(Checker *c, AstNodeUsingStmt *us, AstNode *expr, bo
}
case Entity_Constant:
error(us->token, "`using` cannot be applied to a constant");
error(us->token, "'using' cannot be applied to a constant");
break;
case Entity_Procedure:
case Entity_Builtin:
error(us->token, "`using` cannot be applied to a procedure");
error(us->token, "'using' cannot be applied to a procedure");
break;
case Entity_Nil:
error(us->token, "`using` cannot be applied to `nil`");
error(us->token, "'using' cannot be applied to 'nil'");
break;
case Entity_Label:
error(us->token, "`using` cannot be applied to a label");
error(us->token, "'using' cannot be applied to a label");
break;
case Entity_Invalid:
error(us->token, "`using` cannot be applied to an invalid entity");
error(us->token, "'using' cannot be applied to an invalid entity");
break;
default:
GB_PANIC("TODO(bill): `using` other expressions?");
GB_PANIC("TODO(bill): 'using' other expressions?");
}
return true;
@@ -589,7 +589,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
switch (operand.mode) {
case Addressing_Type: {
gbString str = type_to_string(operand.type);
error(node, "`%s` is not an expression", str);
error(node, "'%s' is not an expression", str);
gb_string_free(str);
break;
@@ -606,14 +606,14 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
if (is_type_proc(t)) {
if (t->Proc.require_results) {
gbString expr_str = expr_to_string(ce->proc);
error(node, "`%s` requires that its results must be handled", expr_str);
error(node, "'%s' requires that its results must be handled", expr_str);
gb_string_free(expr_str);
}
}
return;
}
gbString expr_str = expr_to_string(operand.expr);
error(node, "Expression is not used: `%s`", expr_str);
error(node, "Expression is not used: '%s'", expr_str);
gb_string_free(expr_str);
break;
@@ -717,7 +717,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
check_assignment_variable(c, &lhs_operands[i], &rhs_operands[i]);
}
if (lhs_count != rhs_count) {
error(as->lhs[0], "Assignment count mismatch `%td` = `%td`", lhs_count, rhs_count);
error(as->lhs[0], "Assignment count mismatch '%td' = '%td'", lhs_count, rhs_count);
}
break;
}
@@ -726,11 +726,11 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
// a += 1; // Single-sided
Token op = as->op;
if (as->lhs.count != 1 || as->rhs.count != 1) {
error(op, "Assignment operation `%.*s` requires single-valued expressions", LIT(op.string));
error(op, "Assignment operation '%.*s' requires single-valued expressions", LIT(op.string));
return;
}
if (!gb_is_between(op.kind, Token__AssignOpBegin+1, Token__AssignOpEnd-1)) {
error(op, "Unknown Assignment operation `%.*s`", LIT(op.string));
error(op, "Unknown Assignment operation '%.*s'", LIT(op.string));
return;
}
Operand lhs = {Addressing_Invalid};
@@ -772,7 +772,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
Operand operand = {Addressing_Invalid};
check_expr(c, &operand, is->cond);
if (operand.mode != Addressing_Invalid && !is_type_boolean(operand.type)) {
error(is->cond, "Non-boolean condition in `if` statement");
error(is->cond, "Non-boolean condition in 'if' statement");
}
check_stmt(c, is->body, mod_flags);
@@ -784,7 +784,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
check_stmt(c, is->else_stmt, mod_flags);
break;
default:
error(is->else_stmt, "Invalid `else` statement in `if` statement");
error(is->else_stmt, "Invalid 'else' statement in 'if' statement");
break;
}
}
@@ -800,7 +800,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
GB_ASSERT(c->proc_stack.count > 0);
if (c->context.in_defer) {
error(rs->token, "You cannot `return` within a defer statement");
error(rs->token, "You cannot 'return' within a defer statement");
break;
}
@@ -817,7 +817,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
mix = arg->kind == AstNode_FieldValue;
}
if (mix) {
error(arg, "Mixture of `field = value` and value elements in a procedure all is not allowed");
error(arg, "Mixture of 'field = value' and value elements in a procedure all is not allowed");
fail = true;
}
}
@@ -876,18 +876,18 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
ast_node(fv, FieldValue, arg);
if (fv->field->kind != AstNode_Ident) {
gbString expr_str = expr_to_string(fv->field);
error(arg, "Invalid parameter name `%s` in return statement", expr_str);
error(arg, "Invalid parameter name '%s' in return statement", expr_str);
gb_string_free(expr_str);
continue;
}
String name = fv->field->Ident.token.string;
isize index = lookup_procedure_result(pt, name);
if (index < 0) {
error(arg, "No result named `%.*s` for this procedure type", LIT(name));
error(arg, "No result named '%.*s' for this procedure type", LIT(name));
continue;
}
if (visited[index]) {
error(arg, "Duplicate result `%.*s` in return statement", LIT(name));
error(arg, "Duplicate result '%.*s' in return statement", LIT(name));
continue;
}
@@ -913,7 +913,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
}
gbString str = type_to_string(e->type);
error(node, "Return value `%.*s` of type `%s` is missing in return statement",
error(node, "Return value '%.*s' of type '%s' is missing in return statement",
LIT(e->token.string), str);
gb_string_free(str);
}
@@ -956,7 +956,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
Operand o = {Addressing_Invalid};
check_expr(c, &o, fs->cond);
if (o.mode != Addressing_Invalid && !is_type_boolean(o.type)) {
error(fs->cond, "Non-boolean condition in `for` statement");
error(fs->cond, "Non-boolean condition in 'for' statement");
}
}
if (fs->post != nullptr) {
@@ -964,7 +964,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
if (fs->post->kind != AstNode_AssignStmt &&
fs->post->kind != AstNode_IncDecStmt) {
error(fs->post, "`for` statement post statement must be a simple statement");
error(fs->post, "'for' statement post statement must be a simple statement");
}
}
check_stmt(c, fs->body, new_flags);
@@ -1024,7 +1024,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
gbString xt = type_to_string(x.type);
gbString yt = type_to_string(y.type);
gbString expr_str = expr_to_string(x.expr);
error(ie->op, "Mismatched types in interval expression `%s` : `%s` vs `%s`", expr_str, xt, yt);
error(ie->op, "Mismatched types in interval expression '%s' : '%s' vs '%s'", expr_str, xt, yt);
gb_string_free(expr_str);
gb_string_free(yt);
gb_string_free(xt);
@@ -1078,7 +1078,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
if (operand.mode == Addressing_Type) {
if (!is_type_enum(operand.type)) {
gbString t = type_to_string(operand.type);
error(operand.expr, "Cannot iterate over the type `%s`", t);
error(operand.expr, "Cannot iterate over the type '%s'", t);
gb_string_free(t);
goto skip_expr;
} else {
@@ -1127,7 +1127,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
if (val == nullptr) {
gbString s = expr_to_string(operand.expr);
gbString t = type_to_string(operand.type);
error(operand.expr, "Cannot iterate over `%s` of type `%s`", s, t);
error(operand.expr, "Cannot iterate over '%s' of type '%s'", s, t);
gb_string_free(t);
gb_string_free(s);
}
@@ -1160,7 +1160,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
} else {
TokenPos pos = found->token.pos;
error(token,
"Redeclaration of `%.*s` in this scope\n"
"Redeclaration of '%.*s' in this scope\n"
"\tat %.*s(%td:%td)",
LIT(str), LIT(pos.file), pos.line, pos.column);
entity = found;
@@ -1202,7 +1202,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
}
if (ss->tag != nullptr) {
check_expr(c, &x, ss->tag);
check_assignment(c, &x, nullptr, str_lit("match expression"));
check_assignment(c, &x, nullptr, str_lit("switch expression"));
} else {
x.mode = Addressing_Constant;
x.type = t_bool;
@@ -1215,7 +1215,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
}
if (is_type_vector(x.type)) {
gbString str = type_to_string(x.type);
error(x.expr, "Invalid match expression type: %s", str);
error(x.expr, "Invalid switch expression type: %s", str);
gb_string_free(str);
break;
}
@@ -1240,7 +1240,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
if (first_default != nullptr) {
TokenPos pos = ast_node_token(first_default).pos;
error(stmt,
"multiple `default` clauses\n"
"multiple default clauses\n"
"\tfirst at %.*s(%td:%td)",
LIT(pos.file), pos.line, pos.column);
} else {
@@ -1281,7 +1281,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
if (!is_type_ordered(x.type)) {
gbString str = type_to_string(x.type);
error(x.expr, "Unordered type `%s`, is invalid for an interval expression", str);
error(x.expr, "Unordered type '%s', is invalid for an interval expression", str);
gb_string_free(str);
continue;
}
@@ -1359,7 +1359,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
TokenPos pos = tap.token.pos;
gbString expr_str = expr_to_string(y.expr);
error(y.expr,
"Duplicate case `%s`\n"
"Duplicate case '%s'\n"
"\tprevious case at %.*s(%td:%td)",
expr_str,
LIT(pos.file), pos.line, pos.column);
@@ -1401,32 +1401,32 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
check_open_scope(c, node);
check_label(c, ss->label); // TODO(bill): What should the label's "scope" be?
MatchTypeKind match_type_kind = MatchType_Invalid;
SwitchTypeKind switch_type_kind = SwitchType_Invalid;
if (ss->tag->kind != AstNode_AssignStmt) {
error(ss->tag, "Expected an `in` assignment for this type match statement");
error(ss->tag, "Expected an 'in' assignment for this type switch statement");
break;
}
ast_node(as, AssignStmt, ss->tag);
Token as_token = ast_node_token(ss->tag);
if (as->lhs.count != 1) {
syntax_error(as_token, "Expected 1 name before `in`");
syntax_error(as_token, "Expected 1 name before 'in'");
break;
}
if (as->rhs.count != 1) {
syntax_error(as_token, "Expected 1 expression after `in`");
syntax_error(as_token, "Expected 1 expression after 'in'");
break;
}
AstNode *lhs = as->lhs[0];
AstNode *rhs = as->rhs[0];
check_expr(c, &x, rhs);
check_assignment(c, &x, nullptr, str_lit("type match expression"));
match_type_kind = check_valid_type_match_type(x.type);
if (check_valid_type_match_type(x.type) == MatchType_Invalid) {
check_assignment(c, &x, nullptr, str_lit("type switch expression"));
switch_type_kind = check_valid_type_switch_type(x.type);
if (check_valid_type_switch_type(x.type) == SwitchType_Invalid) {
gbString str = type_to_string(x.type);
error(x.expr, "Invalid type for this type match expression, got `%s`", str);
error(x.expr, "Invalid type for this type switch expression, got '%s'", str);
gb_string_free(str);
break;
}
@@ -1452,7 +1452,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
if (first_default != nullptr) {
TokenPos pos = ast_node_token(first_default).pos;
error(stmt,
"Multiple `default` clauses\n"
"Multiple 'default' clauses\n"
"\tfirst at %.*s(%td:%td)", LIT(pos.file), pos.line, pos.column);
} else {
first_default = default_stmt;
@@ -1462,7 +1462,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
if (lhs->kind != AstNode_Ident) {
error(rhs, "Expected an identifier, got `%.*s`", LIT(ast_node_strings[rhs->kind]));
error(rhs, "Expected an identifier, got '%.*s'", LIT(ast_node_strings[rhs->kind]));
break;
}
@@ -1488,7 +1488,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
Operand y = {};
check_expr_or_type(c, &y, type_expr);
if (match_type_kind == MatchType_Union) {
if (switch_type_kind == SwitchType_Union) {
GB_ASSERT(is_type_union(bt));
bool tag_type_found = false;
for_array(i, bt->Union.variants) {
@@ -1500,15 +1500,15 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
}
if (!tag_type_found) {
gbString type_str = type_to_string(y.type);
error(y.expr, "Unknown tag type, got `%s`", type_str);
error(y.expr, "Unknown tag type, got '%s'", type_str);
gb_string_free(type_str);
continue;
}
case_type = y.type;
} else if (match_type_kind == MatchType_Any) {
} else if (switch_type_kind == SwitchType_Any) {
case_type = y.type;
} else {
GB_PANIC("Unknown type to type match statement");
GB_PANIC("Unknown type to type switch statement");
}
HashKey key = hash_type(y.type);
@@ -1517,7 +1517,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
TokenPos pos = cc->token.pos;
gbString expr_str = expr_to_string(y.expr);
error(y.expr,
"Duplicate type case `%s`\n"
"Duplicate type case '%s'\n"
"\tprevious type case at %.*s(%td:%td)",
expr_str,
LIT(pos.file), pos.line, pos.column);
@@ -1577,21 +1577,21 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
switch (token.kind) {
case Token_break:
if ((flags & Stmt_BreakAllowed) == 0) {
error(token, "`break` only allowed in loops or `match` statements");
error(token, "'break' only allowed in loops or 'switch' statements");
}
break;
case Token_continue:
if ((flags & Stmt_ContinueAllowed) == 0) {
error(token, "`continue` only allowed in loops");
error(token, "'continue' only allowed in loops");
}
break;
case Token_fallthrough:
if ((flags & Stmt_FallthroughAllowed) == 0) {
error(token, "`fallthrough` statement in illegal position");
error(token, "'fallthrough' statement in illegal position");
}
break;
default:
error(token, "Invalid AST: Branch Statement `%.*s`", LIT(token.string));
error(token, "Invalid AST: Branch Statement '%.*s'", LIT(token.string));
break;
}
@@ -1610,7 +1610,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
}
add_entity_use(c, ident, e);
if (e->kind != Entity_Label) {
error(ident, "`%.*s` is not a label", LIT(name));
error(ident, "'%.*s' is not a label", LIT(name));
return;
}
}
@@ -1619,7 +1619,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
case_ast_node(us, UsingStmt, node);
if (us->list.count == 0) {
error(us->token, "Empty `using` list");
error(us->token, "Empty 'using' list");
return;
}
for_array(i, us->list) {
@@ -1637,10 +1637,10 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
is_selector = true;
break;
case AstNode_Implicit:
error(us->token, "`using` applied to an implicit value");
error(us->token, "'using' applied to an implicit value");
continue;
default:
error(us->token, "`using` can only be applied to an entity, got %.*s", LIT(ast_node_strings[expr->kind]));
error(us->token, "'using' can only be applied to an entity, got %.*s", LIT(ast_node_strings[expr->kind]));
continue;
}
@@ -1697,7 +1697,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
Token token = name->Ident.token;
String str = token.string;
Entity *found = nullptr;
// NOTE(bill): Ignore assignments to `_`
// NOTE(bill): Ignore assignments to '_'
if (!is_blank_ident(str)) {
found = current_scope_lookup_entity(c->context.scope, str);
}
@@ -1714,7 +1714,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
} else {
TokenPos pos = found->token.pos;
error(token,
"Redeclaration of `%.*s` in this scope\n"
"Redeclaration of '%.*s' in this scope\n"
"\tat %.*s(%td:%td)",
LIT(str), LIT(pos.file), pos.line, pos.column);
entity = found;
@@ -1734,12 +1734,12 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
init_type = t_invalid;
} else if (is_type_polymorphic(base_type(init_type))) {
gbString str = type_to_string(init_type);
error(vd->type, "Invalid use of a polymorphic type `%s` in variable declaration", str);
error(vd->type, "Invalid use of a polymorphic type '%s' in variable declaration", str);
gb_string_free(str);
init_type = t_invalid;
} else if (is_type_empty_union(init_type)) {
gbString str = type_to_string(init_type);
error(vd->type, "An empty union `%s` cannot be instantiated in variable declaration", str);
error(vd->type, "An empty union '%s' cannot be instantiated in variable declaration", str);
gb_string_free(str);
init_type = t_invalid;
}
@@ -1800,7 +1800,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
Type *other_type = base_type(f->type);
if (!are_types_identical(this_type, other_type)) {
error(e->token,
"Foreign entity `%.*s` previously declared elsewhere with a different type\n"
"Foreign entity '%.*s' previously declared elsewhere with a different type\n"
"\tat %.*s(%td:%td)",
LIT(name), LIT(pos.file), pos.line, pos.column);
}
@@ -1814,8 +1814,8 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
if (vd->is_using != 0) {
Token token = ast_node_token(node);
if (vd->type != nullptr && entity_count > 1) {
error(token, "`using` can only be applied to one variable of the same type");
// TODO(bill): Should a `continue` happen here?
error(token, "'using' can only be applied to one variable of the same type");
// TODO(bill): Should a 'continue' happen here?
}
for (isize entity_index = 0; entity_index < entity_count; entity_index++) {
@@ -1831,7 +1831,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
Type *t = base_type(type_deref(e->type));
if (is_blank_ident(name)) {
error(token, "`using` cannot be applied variable declared as `_`");
error(token, "'using' cannot be applied variable declared as '_'");
} else if (is_type_struct(t) || is_type_raw_union(t)) {
Scope *scope = scope_of_node(&c->info, t->Struct.node);
for_array(i, scope->elements.entries) {
@@ -1841,14 +1841,14 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
uvar->Variable.is_immutable = is_immutable;
Entity *prev = scope_insert_entity(c->context.scope, uvar);
if (prev != nullptr) {
error(token, "Namespace collision while `using` `%.*s` of: %.*s", LIT(name), LIT(prev->token.string));
error(token, "Namespace collision while 'using' '%.*s' of: %.*s", LIT(name), LIT(prev->token.string));
return;
}
}
}
} else {
// NOTE(bill): skip the rest to remove extra errors
error(token, "`using` can only be applied to variables of type struct or raw_union");
error(token, "'using' can only be applied to variables of type struct or raw_union");
return;
}
}

View File

@@ -18,9 +18,9 @@ void populate_using_entity_map(Checker *c, AstNode *node, Type *t, Map<Entity *>
Entity *e = *found;
// TODO(bill): Better type error
if (str != nullptr) {
error(e->token, "`%.*s` is already declared in `%s`", LIT(name), str);
error(e->token, "'%.*s' is already declared in '%s'", LIT(name), str);
} else {
error(e->token, "`%.*s` is already declared`", LIT(name));
error(e->token, "'%.*s' is already declared", LIT(name));
}
} else {
map_set(entity_map, key, f);
@@ -42,11 +42,11 @@ void check_struct_field_decl(Checker *c, AstNode *decl, Array<Entity *> *fields,
Operand operand = {Addressing_Invalid};
check_expr(c, &operand, ws->cond);
if (operand.mode != Addressing_Constant || !is_type_boolean(operand.type)) {
error(ws->cond, "Non-constant boolean `when` condition");
error(ws->cond, "Non-constant boolean 'when' condition");
return;
}
if (ws->body == nullptr || ws->body->kind != AstNode_BlockStmt) {
error(ws->cond, "Invalid body for `when` statement");
error(ws->cond, "Invalid body for 'when' statement");
return;
}
if (operand.value.kind == ExactValue_Bool &&
@@ -67,7 +67,7 @@ void check_struct_field_decl(Checker *c, AstNode *decl, Array<Entity *> *fields,
check_struct_field_decl(c, ws->else_stmt, fields, entity_map, struct_node, context, allow_default_values);
break;
default:
error(ws->else_stmt, "Invalid `else` statement in `when` statement");
error(ws->else_stmt, "Invalid 'else' statement in 'when' statement");
break;
}
}
@@ -85,7 +85,7 @@ void check_struct_field_decl(Checker *c, AstNode *decl, Array<Entity *> *fields,
bool is_using = vd->is_using;
if (is_using && vd->names.count > 1) {
error(vd->names[0], "Cannot apply `using` to more than one of the same type");
error(vd->names[0], "Cannot apply 'using' to more than one of the same type");
is_using = false;
}
@@ -175,7 +175,7 @@ void check_struct_field_decl(Checker *c, AstNode *decl, Array<Entity *> *fields,
error(b.expr, "Default field value must be a constant");
} else if (is_type_any(e->type) || is_type_union(e->type)) {
gbString str = type_to_string(e->type);
error(b.expr, "A struct field of type `%s` cannot have a default value", str);
error(b.expr, "A struct field of type '%s' cannot have a default value", str);
gb_string_free(str);
} else {
e->Variable.default_value = b.value;
@@ -196,7 +196,7 @@ void check_struct_field_decl(Checker *c, AstNode *decl, Array<Entity *> *fields,
Entity *e = *found;
// NOTE(bill): Scope checking already checks the declaration but in many cases, this can happen so why not?
// This may be a little janky but it's not really that much of a problem
error(name_token, "`%.*s` is already declared in this type", LIT(name_token.string));
error(name_token, "'%.*s' is already declared in this type", LIT(name_token.string));
error(e->token, "\tpreviously declared");
} else {
map_set(entity_map, key, e);
@@ -235,11 +235,11 @@ void check_struct_field_decl(Checker *c, AstNode *decl, Array<Entity *> *fields,
using_index_expr = (*fields)[fields->count-1];
} else {
(*fields)[fields->count-1]->flags &= ~EntityFlag_Using;
error(name_token, "Previous `using` for an index expression `%.*s`", LIT(name_token.string));
error(name_token, "Previous 'using' for an index expression '%.*s'", LIT(name_token.string));
}
} else {
gbString type_str = type_to_string(first_type);
error(name_token, "`using` cannot be applied to the field `%.*s` of type `%s`", LIT(name_token.string), type_str);
error(name_token, "'using' cannot be applied to the field '%.*s' of type '%s'", LIT(name_token.string), type_str);
gb_string_free(type_str);
return;
}
@@ -382,7 +382,7 @@ Array<Entity *> check_struct_fields(Checker *c, AstNode *node, Array<AstNode *>
}
if (is_type_empty_union(type)) {
gbString str = type_to_string(type);
error(params[i], "Invalid use of an empty union `%s`", str);
error(params[i], "Invalid use of an empty union '%s'", str);
gb_string_free(str);
type = t_invalid;
}
@@ -436,11 +436,11 @@ Array<Entity *> check_struct_fields(Checker *c, AstNode *node, Array<AstNode *>
using_index_expr = fields[fields.count-1];
} else {
fields[fields.count-1]->flags &= ~EntityFlag_Using;
error(name_token, "Previous `using` for an index expression `%.*s`", LIT(name_token.string));
error(name_token, "Previous 'using' for an index expression '%.*s'", LIT(name_token.string));
}
} else {
gbString type_str = type_to_string(first_type);
error(name_token, "`using` cannot be applied to the field `%.*s` of type `%s`", LIT(name_token.string), type_str);
error(name_token, "'using' cannot be applied to the field '%.*s' of type '%s'", LIT(name_token.string), type_str);
gb_string_free(type_str);
continue;
}
@@ -465,7 +465,7 @@ gb_global gbAllocator __checker_allocator = {};
GB_COMPARE_PROC(cmp_reorder_struct_fields) {
// Rule:
// `using` over non-`using`
// 'using' over non-'using'
// Biggest to smallest alignment
// if same alignment: biggest to smallest size
// if same size: order by source order
@@ -847,7 +847,7 @@ void check_struct_type(Checker *c, Type *struct_type, AstNode *node, Array<Opera
if (st->align != nullptr) {
if (st->is_packed) {
syntax_error(st->align, "`#align` cannot be applied with `#packed`");
syntax_error(st->align, "'#align' cannot be applied with '#packed'");
return;
}
i64 custom_align = 1;
@@ -881,14 +881,14 @@ void check_union_type(Checker *c, Type *union_type, AstNode *node) {
if (is_type_untyped(t) || is_type_empty_union(t)) {
ok = false;
gbString str = type_to_string(t);
error(node, "Invalid variant type in union `%s`", str);
error(node, "Invalid variant type in union '%s'", str);
gb_string_free(str);
} else {
for_array(j, variants) {
if (are_types_identical(t, variants[j])) {
ok = false;
gbString str = type_to_string(t);
error(node, "Duplicate variant type `%s`", str);
error(node, "Duplicate variant type '%s'", str);
gb_string_free(str);
break;
}
@@ -935,7 +935,7 @@ void check_enum_type(Checker *c, Type *enum_type, Type *named_type, AstNode *nod
return;
}
// NOTE(bill): Must be up here for the `check_init_constant` system
// NOTE(bill): Must be up here for the 'check_init_constant' system
enum_type->Enum.base_type = base_type;
Map<Entity *> entity_map = {}; // Key: String
@@ -997,19 +997,19 @@ void check_enum_type(Checker *c, Type *enum_type, Type *named_type, AstNode *nod
if (is_blank_ident(name)) {
continue;
} else if (name == "count") {
error(field, "`count` is a reserved identifier for enumerations");
error(field, "'count' is a reserved identifier for enumerations");
continue;
} else if (name == "min_value") {
error(field, "`min_value` is a reserved identifier for enumerations");
error(field, "'min_value' is a reserved identifier for enumerations");
continue;
} else if (name == "max_value") {
error(field, "`max_value` is a reserved identifier for enumerations");
error(field, "'max_value' is a reserved identifier for enumerations");
continue;
} else if (name == "names") {
error(field, "`names` is a reserved identifier for enumerations");
error(field, "'names' is a reserved identifier for enumerations");
continue;
}/* else if (name == "base_type") {
error(field, "`base_type` is a reserved identifier for enumerations");
error(field, "'base_type' is a reserved identifier for enumerations");
continue;
} */
@@ -1026,7 +1026,7 @@ void check_enum_type(Checker *c, Type *enum_type, Type *named_type, AstNode *nod
HashKey key = hash_string(name);
if (map_get(&entity_map, key) != nullptr) {
error(ident, "`%.*s` is already declared in this enumeration", LIT(name));
error(ident, "'%.*s' is already declared in this enumeration", LIT(name));
} else {
map_set(&entity_map, key, e);
add_entity(c, c->context.scope, nullptr, e);
@@ -1104,7 +1104,7 @@ void check_bit_field_type(Checker *c, Type *bit_field_type, AstNode *node) {
HashKey key = hash_string(name);
if (!is_blank_ident(name) &&
map_get(&entity_map, key) != nullptr) {
error(ident, "`%.*s` is already declared in this bit field", LIT(name));
error(ident, "'%.*s' is already declared in this bit field", LIT(name));
} else {
map_set(&entity_map, key, e);
add_entity(c, c->context.scope, nullptr, e);
@@ -1204,7 +1204,7 @@ Type *determine_type_from_polymorphic(Checker *c, Type *poly_type, Operand opera
gbString ots = type_to_string(operand.type);
defer (gb_string_free(pts));
defer (gb_string_free(ots));
error(operand.expr, "Cannot determine polymorphic type from parameter: `%s` to `%s`", ots, pts);
error(operand.expr, "Cannot determine polymorphic type from parameter: '%s' to '%s'", ots, pts);
}
return t_invalid;
}
@@ -1432,7 +1432,7 @@ Type *check_get_params(Checker *c, Scope *scope, AstNode *_params, bool *is_vari
}
if (is_type_empty_union(type)) {
gbString str = type_to_string(type);
error(param, "Invalid use of an empty union `%s`", str);
error(param, "Invalid use of an empty union '%s'", str);
gb_string_free(str);
type = t_invalid;
}
@@ -1441,7 +1441,7 @@ Type *check_get_params(Checker *c, Scope *scope, AstNode *_params, bool *is_vari
if (p->flags&FieldFlag_c_vararg) {
if (p->type == nullptr ||
p->type->kind != AstNode_Ellipsis) {
error(param, "`#c_vararg` can only be applied to variadic type fields");
error(param, "'#c_vararg' can only be applied to variadic type fields");
p->flags &= ~FieldFlag_c_vararg; // Remove the flag
} else {
is_c_vararg = true;
@@ -1450,10 +1450,10 @@ Type *check_get_params(Checker *c, Scope *scope, AstNode *_params, bool *is_vari
if (is_constant_value) {
if (is_type_param) {
error(param, "`$` is not needed for a `type` parameter");
error(param, "'$' is not needed for a 'type' parameter");
}
if (p->flags&FieldFlag_no_alias) {
error(param, "`#no_alias` can only be applied to variable fields of pointer type");
error(param, "'#no_alias' can only be applied to variable fields of pointer type");
p->flags &= ~FieldFlag_no_alias; // Remove the flag
}
@@ -1480,7 +1480,7 @@ Type *check_get_params(Checker *c, Scope *scope, AstNode *_params, bool *is_vari
}
if (is_type_polymorphic(type)) {
gbString str = type_to_string(type);
error(o.expr, "Cannot pass polymorphic type as a parameter, got `%s`", str);
error(o.expr, "Cannot pass polymorphic type as a parameter, got '%s'", str);
gb_string_free(str);
success = false;
type = t_invalid;
@@ -1491,7 +1491,7 @@ Type *check_get_params(Checker *c, Scope *scope, AstNode *_params, bool *is_vari
if (!c->context.no_polymorphic_errors) {
gbString t = type_to_string(type);
gbString s = type_to_string(specialization);
error(o.expr, "Cannot convert type `%s` to the specialization `%s`", t, s);
error(o.expr, "Cannot convert type '%s' to the specialization '%s'", t, s);
gb_string_free(s);
gb_string_free(t);
}
@@ -1517,7 +1517,7 @@ Type *check_get_params(Checker *c, Scope *scope, AstNode *_params, bool *is_vari
if (p->flags&FieldFlag_no_alias) {
if (!is_type_pointer(type)) {
error(name, "`#no_alias` can only be applied to fields of pointer type");
error(name, "'#no_alias' can only be applied to fields of pointer type");
p->flags &= ~FieldFlag_no_alias; // Remove the flag
}
}
@@ -1713,7 +1713,7 @@ Type *check_get_results(Checker *c, Scope *scope, AstNode *_results) {
continue;
}
if (x == y) {
error(variables[j]->token, "Duplicate return value name `%.*s`", LIT(y));
error(variables[j]->token, "Duplicate return value name '%.*s'", LIT(y));
}
}
}
@@ -1912,7 +1912,7 @@ bool abi_compat_return_by_value(gbAllocator a, ProcCallingConvention cc, Type *a
return false;
}
// NOTE(bill): `operands` is for generating non generic procedure type
// NOTE(bill): 'operands' is for generating non generic procedure type
bool check_procedure_type(Checker *c, Type *type, AstNode *proc_type_node, Array<Operand> *operands) {
ast_node(pt, ProcType, proc_type_node);
@@ -2147,7 +2147,7 @@ void check_map_type(Checker *c, Type *type, AstNode *node) {
error(node, "A boolean cannot be used as a key for a map, use an array instead for this case");
} else {
gbString str = type_to_string(key);
error(node, "Invalid type of a key for a map, got `%s`", str);
error(node, "Invalid type of a key for a map, got '%s'", str);
gb_string_free(str);
}
}
@@ -2159,7 +2159,7 @@ void check_map_type(Checker *c, Type *type, AstNode *node) {
init_preload(c);
generate_map_internal_types(c->allocator, type);
// error(node, "`map` types are not yet implemented");
// error(node, "'map' types are not yet implemented");
}
bool check_type_internal(Checker *c, AstNode *e, Type **type, Type *named_type) {
@@ -2185,13 +2185,13 @@ bool check_type_internal(Checker *c, AstNode *e, Type **type, Type *named_type)
case Addressing_NoValue:
err_str = expr_to_string(e);
error(e, "`%s` used as a type", err_str);
error(e, "'%s' used as a type", err_str);
gb_string_free(err_str);
break;
default:
err_str = expr_to_string(e);
error(e, "`%s` used as a type when not a type", err_str);
error(e, "'%s' used as a type when not a type", err_str);
gb_string_free(err_str);
break;
}
@@ -2202,7 +2202,7 @@ bool check_type_internal(Checker *c, AstNode *e, Type **type, Type *named_type)
case_end;
case_ast_node(at, AliasType, e);
error(e, "Invalid use of `#alias`");
error(e, "Invalid use of '#alias'");
// NOTE(bill): Treat it as a HelperType to remove errors
return check_type_internal(c, at->type, type, named_type);
case_end;
@@ -2241,7 +2241,7 @@ bool check_type_internal(Checker *c, AstNode *e, Type **type, Type *named_type)
add_entity(c, ps, ident, e);
add_entity(c, s, ident, e);
} else {
error(ident, "Invalid use of a polymorphic parameter `$%.*s`", LIT(token.string));
error(ident, "Invalid use of a polymorphic parameter '$%.*s'", LIT(token.string));
*type = t_invalid;
return false;
}
@@ -2263,12 +2263,12 @@ bool check_type_internal(Checker *c, AstNode *e, Type **type, Type *named_type)
return true;
case Addressing_NoValue:
err_str = expr_to_string(e);
error(e, "`%s` used as a type", err_str);
error(e, "'%s' used as a type", err_str);
gb_string_free(err_str);
break;
default:
err_str = expr_to_string(e);
error(e, "`%s` is not a type", err_str);
error(e, "'%s' is not a type", err_str);
gb_string_free(err_str);
break;
}
@@ -2341,7 +2341,7 @@ bool check_type_internal(Checker *c, AstNode *e, Type **type, Type *named_type)
Type *be = base_type(elem);
if (is_type_vector(be) || (!is_type_boolean(be) && !is_type_numeric(be) && be->kind != Type_Generic)) {
gbString err_str = type_to_string(elem);
error(vt->elem, "Vector element type must be numerical or a boolean, got `%s`", err_str);
error(vt->elem, "Vector element type must be numerical or a boolean, got '%s'", err_str);
gb_string_free(err_str);
}
*type = make_type_vector(c->allocator, elem, count, generic_type);
@@ -2434,7 +2434,7 @@ Type *check_type(Checker *c, AstNode *e, Type *named_type) {
if (!ok) {
gbString err_str = expr_to_string(e);
error(e, "`%s` is not a type", err_str);
error(e, "'%s' is not a type", err_str);
gb_string_free(err_str);
type = t_invalid;
}
@@ -2447,7 +2447,7 @@ Type *check_type(Checker *c, AstNode *e, Type *named_type) {
type->Named.base == nullptr) {
// IMPORTANT TODO(bill): Is this a serious error?!
#if 0
error(e, "Invalid type definition of `%.*s`", LIT(type->Named.name));
error(e, "Invalid type definition of '%.*s'", LIT(type->Named.name));
#endif
type->Named.base = t_invalid;
}
@@ -2455,7 +2455,7 @@ Type *check_type(Checker *c, AstNode *e, Type *named_type) {
#if 0
if (!c->context.allow_polymorphic_types && is_type_polymorphic(type)) {
gbString str = type_to_string(type);
error(e, "Invalid use of a polymorphic type `%s`", str);
error(e, "Invalid use of a polymorphic type '%s'", str);
gb_string_free(str);
type = t_invalid;
}

View File

@@ -230,7 +230,7 @@ struct Scope {
Array<Scope *> shared;
Array<AstNode *> delayed_file_decls;
PtrSet<Scope *> imported;
PtrSet<Scope *> exported; // NOTE(bhall): Contains `using import` too
PtrSet<Scope *> exported; // NOTE(bhall): Contains 'using import' too
bool is_proc;
bool is_global;
bool is_file;
@@ -617,7 +617,7 @@ void destroy_scope(Scope *scope) {
if (e->kind == Entity_Variable) {
if (!(e->flags & EntityFlag_Used)) {
#if 0
warning(e->token, "Unused variable `%.*s`", LIT(e->token.string));
warning(e->token, "Unused variable '%.*s'", LIT(e->token.string));
#endif
}
}
@@ -833,7 +833,7 @@ void add_declaration_dependency(Checker *c, Entity *e) {
Entity *add_global_entity(Entity *entity) {
String name = entity->token.string;
if (gb_memchr(name.text, ' ', name.len)) {
return entity; // NOTE(bill): `untyped thing`
return entity; // NOTE(bill): 'untyped thing'
}
if (scope_insert_entity(universal_scope, entity)) {
compiler_error("double declaration");
@@ -1123,7 +1123,7 @@ isize type_info_index(CheckerInfo *info, Type *type, bool error_on_failure) {
}
if (error_on_failure && entry_index < 0) {
compiler_error("TypeInfo for `%s` could not be found", type_to_string(type));
compiler_error("TypeInfo for '%s' could not be found", type_to_string(type));
}
return entry_index;
}
@@ -1189,7 +1189,7 @@ bool add_entity(Checker *c, Scope *scope, AstNode *identifier, Entity *entity) {
return false;
}
error(entity->token,
"Redeclaration of `%.*s` in this scope through `using`\n"
"Redeclaration of '%.*s' in this scope through 'using'\n"
"\tat %.*s(%td:%td)",
LIT(name),
LIT(up->token.pos.file), up->token.pos.line, up->token.pos.column);
@@ -1200,7 +1200,7 @@ bool add_entity(Checker *c, Scope *scope, AstNode *identifier, Entity *entity) {
return false;
}
error(entity->token,
"Redeclaration of `%.*s` in this scope\n"
"Redeclaration of '%.*s' in this scope\n"
"\tat %.*s(%td:%td)",
LIT(name),
LIT(pos.file), pos.line, pos.column);
@@ -1565,26 +1565,26 @@ Array<EntityGraphNode *> generate_entity_dependency_graph(CheckerInfo *info) {
EntityGraphNode *n = entry->value;
if (e->kind == Entity_Procedure) {
// Connect each pred `p` of `n` with each succ `s` and from
// Connect each pred 'p' of 'n' with each succ 's' and from
// the procedure node
for_array(j, n->pred.entries) {
EntityGraphNode *p = cast(EntityGraphNode *)n->pred.entries[j].ptr;
// Ignore self-cycles
if (p != n) {
// Each succ `s` of `n` becomes a succ of `p`, and
// each pred `p` of `n` becomes a pred of `s`
// Each succ 's' of 'n' becomes a succ of 'p', and
// each pred 'p' of 'n' becomes a pred of 's'
for_array(k, n->succ.entries) {
EntityGraphNode *s = n->succ.entries[k].ptr;
// Ignore self-cycles
if (s != n) {
entity_graph_node_set_add(&p->succ, s);
entity_graph_node_set_add(&s->pred, p);
// Remove edge to `n`
// Remove edge to 'n'
entity_graph_node_set_remove(&s->pred, n);
}
}
// Remove edge to `n`
// Remove edge to 'n'
entity_graph_node_set_remove(&p->succ, n);
}
}
@@ -1609,8 +1609,8 @@ Array<EntityGraphNode *> generate_entity_dependency_graph(CheckerInfo *info) {
Entity *find_core_entity(Checker *c, String name) {
Entity *e = current_scope_lookup_entity(c->global_scope, name);
if (e == nullptr) {
compiler_error("Could not find type declaration for `%.*s`\n"
"Is `_preload.odin` missing from the `core` directory relative to odin.exe?", LIT(name));
compiler_error("Could not find type declaration for '%.*s'\n"
"Is '_preload.odin' missing from the 'core' directory relative to odin.exe?", LIT(name));
// NOTE(bill): This will exit the program as it's cannot continue without it!
}
return e;
@@ -1619,8 +1619,8 @@ Entity *find_core_entity(Checker *c, String name) {
Type *find_core_type(Checker *c, String name) {
Entity *e = current_scope_lookup_entity(c->global_scope, name);
if (e == nullptr) {
compiler_error("Could not find type declaration for `%.*s`\n"
"Is `_preload.odin` missing from the `core` directory relative to odin.exe?", LIT(name));
compiler_error("Could not find type declaration for '%.*s'\n"
"Is '_preload.odin' missing from the 'core' directory relative to odin.exe?", LIT(name));
// NOTE(bill): This will exit the program as it's cannot continue without it!
}
return e->type;
@@ -1812,25 +1812,25 @@ void check_procedure_overloading(Checker *c, Entity *e) {
ProcTypeOverloadKind kind = are_proc_types_overload_safe(p->type, q->type);
switch (kind) {
case ProcOverload_Identical:
error(p->token, "Overloaded procedure `%.*s` as the same type as another procedure in this scope", LIT(name));
error(p->token, "Overloaded procedure '%.*s' as the same type as another procedure in this scope", LIT(name));
is_invalid = true;
break;
// case ProcOverload_CallingConvention:
// error(p->token, "Overloaded procedure `%.*s` as the same type as another procedure in this scope", LIT(name));
// error(p->token, "Overloaded procedure '%.*s' as the same type as another procedure in this scope", LIT(name));
// is_invalid = true;
// break;
case ProcOverload_ParamVariadic:
error(p->token, "Overloaded procedure `%.*s` as the same type as another procedure in this scope", LIT(name));
error(p->token, "Overloaded procedure '%.*s' as the same type as another procedure in this scope", LIT(name));
is_invalid = true;
break;
case ProcOverload_ResultCount:
case ProcOverload_ResultTypes:
error(p->token, "Overloaded procedure `%.*s` as the same parameters but different results in this scope", LIT(name));
error(p->token, "Overloaded procedure '%.*s' as the same parameters but different results in this scope", LIT(name));
is_invalid = true;
break;
case ProcOverload_Polymorphic:
#if 0
error(p->token, "Overloaded procedure `%.*s` has a polymorphic counterpart in this scope which is not allowed", LIT(name));
error(p->token, "Overloaded procedure '%.*s' has a polymorphic counterpart in this scope which is not allowed", LIT(name));
is_invalid = true;
#endif
break;
@@ -1883,24 +1883,24 @@ DECL_ATTRIBUTE_PROC(foreign_block_decl_attribute) {
if (value.kind == ExactValue_String) {
auto cc = string_to_calling_convention(value.value_string);
if (cc == ProcCC_Invalid) {
error(elem, "Unknown procedure calling convention: `%.*s`\n", LIT(value.value_string));
error(elem, "Unknown procedure calling convention: '%.*s'\n", LIT(value.value_string));
} else {
c->context.foreign_context.default_cc = cc;
}
} else {
error(elem, "Expected a string value for `%.*s`", LIT(name));
error(elem, "Expected a string value for '%.*s'", LIT(name));
}
return true;
} else if (name == "link_prefix") {
if (value.kind == ExactValue_String) {
String link_prefix = value.value_string;
if (!is_foreign_name_valid(link_prefix)) {
error(elem, "Invalid link prefix: `%.*s`\n", LIT(link_prefix));
error(elem, "Invalid link prefix: '%.*s'\n", LIT(link_prefix));
} else {
c->context.foreign_context.link_prefix = link_prefix;
}
} else {
error(elem, "Expected a string value for `%.*s`", LIT(name));
error(elem, "Expected a string value for '%.*s'", LIT(name));
}
return true;
}
@@ -1916,7 +1916,7 @@ DECL_ATTRIBUTE_PROC(proc_decl_attribute) {
error(elem, "Invalid link name: %.*s", LIT(ac->link_name));
}
} else {
error(elem, "Expected a string value for `%.*s`", LIT(name));
error(elem, "Expected a string value for '%.*s'", LIT(name));
}
return true;
} else if (name == "link_prefix") {
@@ -1926,7 +1926,7 @@ DECL_ATTRIBUTE_PROC(proc_decl_attribute) {
error(elem, "Invalid link prefix: %.*s", LIT(ac->link_prefix));
}
} else {
error(elem, "Expected a string value for `%.*s`", LIT(name));
error(elem, "Expected a string value for '%.*s'", LIT(name));
}
return true;
}
@@ -1935,7 +1935,7 @@ DECL_ATTRIBUTE_PROC(proc_decl_attribute) {
DECL_ATTRIBUTE_PROC(var_decl_attribute) {
if (c->context.curr_proc_decl != nullptr) {
error(elem, "Only a variable at file scope can have a `%.*s`", LIT(name));
error(elem, "Only a variable at file scope can have a '%.*s'", LIT(name));
return true;
}
@@ -1946,7 +1946,7 @@ DECL_ATTRIBUTE_PROC(var_decl_attribute) {
error(elem, "Invalid link name: %.*s", LIT(ac->link_name));
}
} else {
error(elem, "Expected a string value for `%.*s`", LIT(name));
error(elem, "Expected a string value for '%.*s'", LIT(name));
}
return true;
} else if (name == "link_prefix") {
@@ -1956,7 +1956,7 @@ DECL_ATTRIBUTE_PROC(var_decl_attribute) {
error(elem, "Invalid link prefix: %.*s", LIT(ac->link_prefix));
}
} else {
error(elem, "Expected a string value for `%.*s`", LIT(name));
error(elem, "Expected a string value for '%.*s'", LIT(name));
}
return true;
} else if (name == "thread_local") {
@@ -1973,10 +1973,10 @@ DECL_ATTRIBUTE_PROC(var_decl_attribute) {
model == "localexec") {
ac->thread_local_model = model;
} else {
error(elem, "Invalid thread local model `%.*s`", LIT(model));
error(elem, "Invalid thread local model '%.*s'", LIT(model));
}
} else {
error(elem, "Expected either no value or a string for `%.*s`", LIT(name));
error(elem, "Expected either no value or a string for '%.*s'", LIT(name));
}
return true;
}
@@ -2039,14 +2039,14 @@ void check_decl_attributes(Checker *c, Array<AstNode *> attributes, DeclAttribut
}
if (string_set_exists(&set, name)) {
error(elem, "Previous declaration of `%.*s`", LIT(name));
error(elem, "Previous declaration of '%.*s'", LIT(name));
continue;
} else {
string_set_add(&set, name);
}
if (!proc(c, elem, name, ev, ac)) {
error(elem, "Unknown attribute element name `%.*s`", LIT(name));
error(elem, "Unknown attribute element name '%.*s'", LIT(name));
}
}
}
@@ -2075,7 +2075,7 @@ bool check_arity_match(Checker *c, AstNodeValueDecl *vd, bool is_global) {
if (lhs < vd->values.count) {
AstNode *n = vd->values[lhs];
gbString str = expr_to_string(n);
error(n, "Extra initial expression `%s`", str);
error(n, "Extra initial expression '%s'", str);
gb_string_free(str);
} else {
error(vd->names[0], "Extra initial expression");
@@ -2085,7 +2085,7 @@ bool check_arity_match(Checker *c, AstNodeValueDecl *vd, bool is_global) {
if (!is_global && rhs != 1) {
AstNode *n = vd->names[rhs];
gbString str = expr_to_string(n);
error(n, "Missing expression for `%s`", str);
error(n, "Missing expression for '%s'", str);
gb_string_free(str);
return false;
} else if (is_global) {
@@ -2103,10 +2103,10 @@ void check_collect_entities_from_when_stmt(Checker *c, AstNodeWhenStmt *ws) {
if (!ws->is_cond_determined) {
check_expr(c, &operand, ws->cond);
if (operand.mode != Addressing_Invalid && !is_type_boolean(operand.type)) {
error(ws->cond, "Non-boolean condition in `when` statement");
error(ws->cond, "Non-boolean condition in 'when' statement");
}
if (operand.mode != Addressing_Constant) {
error(ws->cond, "Non-constant condition in `when` statement");
error(ws->cond, "Non-constant condition in 'when' statement");
}
ws->is_cond_determined = true;
@@ -2114,7 +2114,7 @@ void check_collect_entities_from_when_stmt(Checker *c, AstNodeWhenStmt *ws) {
}
if (ws->body == nullptr || ws->body->kind != AstNode_BlockStmt) {
error(ws->cond, "Invalid body for `when` statement");
error(ws->cond, "Invalid body for 'when' statement");
} else {
if (ws->determined_cond) {
check_collect_entities(c, ws->body->BlockStmt.stmts);
@@ -2127,7 +2127,7 @@ void check_collect_entities_from_when_stmt(Checker *c, AstNodeWhenStmt *ws) {
check_collect_entities_from_when_stmt(c, &ws->else_stmt->WhenStmt);
break;
default:
error(ws->else_stmt, "Invalid `else` statement in `when` statement");
error(ws->else_stmt, "Invalid 'else' statement in 'when' statement");
break;
}
}
@@ -2176,7 +2176,7 @@ void check_collect_value_decl(Checker *c, AstNode *decl) {
if (vd->is_using) {
vd->is_using = false; // NOTE(bill): This error will be only caught once
error(name, "`using` is not allowed at the file scope");
error(name, "'using' is not allowed at the file scope");
}
AstNode *fl = c->context.foreign_context.curr_library;
@@ -2282,7 +2282,7 @@ void check_collect_value_decl(Checker *c, AstNode *decl) {
AstNodeKind kind = init->kind;
error(name, "Only procedures and variables are allowed to be in a foreign block, got %.*s", LIT(ast_node_strings[kind]));
if (kind == AstNode_ProcType) {
gb_printf_err("\tDid you forget to append `---` to the procedure?\n");
gb_printf_err("\tDid you forget to append '---' to the procedure?\n");
}
}
}
@@ -2309,7 +2309,7 @@ void check_add_foreign_block_decl(Checker *c, AstNode *decl) {
} else if (foreign_library->kind == AstNode_Implicit && foreign_library->Implicit.kind == Token_export) {
c->context.foreign_context.in_export = true;
} else {
error(foreign_library, "Foreign block name must be an identifier or `export`");
error(foreign_library, "Foreign block name must be an identifier or 'export'");
c->context.foreign_context.curr_library = nullptr;
}
@@ -2386,7 +2386,7 @@ void check_collect_entities(Checker *c, Array<AstNode *> nodes) {
}
}
// NOTE(bill): `when` stmts need to be handled after the other as the condition may refer to something
// NOTE(bill): 'when' stmts need to be handled after the other as the condition may refer to something
// declared after this stmt in source
if (!c->context.scope->is_file || c->context.collect_delayed_decls) {
for_array(i, nodes) {
@@ -2427,11 +2427,11 @@ void check_all_global_entities(Checker *c) {
if (e->token.string == "main") {
if (e->kind != Entity_Procedure) {
if (e->scope->is_init) {
error(e->token, "`main` is reserved as the entry point procedure in the initial scope");
error(e->token, "'main' is reserved as the entry point procedure in the initial scope");
continue;
}
} else if (e->scope->is_global) {
error(e->token, "`main` is reserved as the entry point procedure in the initial scope");
error(e->token, "'main' is reserved as the entry point procedure in the initial scope");
continue;
}
}
@@ -2563,7 +2563,7 @@ void add_import_dependency_node(Checker *c, AstNode *decl, Map<ImportGraphNode *
GB_ASSERT(found_node != nullptr);
n = *found_node;
// TODO(bill): How should the edges be attched for `import`?
// TODO(bill): How should the edges be attched for 'import'?
import_graph_node_set_add(&n->succ, m);
import_graph_node_set_add(&m->pred, n);
ptr_set_add(&m->scope->imported, n->scope);
@@ -2825,7 +2825,7 @@ void check_add_export_decl(Checker *c, AstNodeExportDecl *ed) {
}
if (parent_scope->is_global) {
error(ed->token, "`export` cannot be used on #shared_global_scope");
error(ed->token, "'export' cannot be used on #shared_global_scope");
return;
}
@@ -2877,10 +2877,10 @@ void check_add_foreign_import_decl(Checker *c, AstNode *decl) {
switch (file_err) {
case gbFileError_Invalid:
error(decl, "Invalid file or cannot be found (`%.*s`)", LIT(fullpath));
error(decl, "Invalid file or cannot be found ('%.*s')", LIT(fullpath));
return;
case gbFileError_NotExists:
error(decl, "File cannot be found (`%.*s`)", LIT(fullpath));
error(decl, "File cannot be found ('%.*s')", LIT(fullpath));
return;
}
}
@@ -2930,10 +2930,10 @@ bool collect_checked_files_from_when_stmt(Checker *c, AstNodeWhenStmt *ws) {
if (!ws->is_cond_determined) {
check_expr(c, &operand, ws->cond);
if (operand.mode != Addressing_Invalid && !is_type_boolean(operand.type)) {
error(ws->cond, "Non-boolean condition in `when` statement");
error(ws->cond, "Non-boolean condition in 'when' statement");
}
if (operand.mode != Addressing_Constant) {
error(ws->cond, "Non-constant condition in `when` statement");
error(ws->cond, "Non-constant condition in 'when' statement");
}
ws->is_cond_determined = true;
@@ -2941,7 +2941,7 @@ bool collect_checked_files_from_when_stmt(Checker *c, AstNodeWhenStmt *ws) {
}
if (ws->body == nullptr || ws->body->kind != AstNode_BlockStmt) {
error(ws->cond, "Invalid body for `when` statement");
error(ws->cond, "Invalid body for 'when' statement");
} else {
if (ws->determined_cond) {
return collect_checked_files_from_import_decl_list(c, ws->body->BlockStmt.stmts);
@@ -2952,7 +2952,7 @@ bool collect_checked_files_from_when_stmt(Checker *c, AstNodeWhenStmt *ws) {
case AstNode_WhenStmt:
return collect_checked_files_from_when_stmt(c, &ws->else_stmt->WhenStmt);
default:
error(ws->else_stmt, "Invalid `else` statement in `when` statement");
error(ws->else_stmt, "Invalid 'else' statement in 'when' statement");
break;
}
}
@@ -2994,10 +2994,10 @@ bool collect_file_decls_from_when_stmt(Checker *c, AstNodeWhenStmt *ws) {
if (!ws->is_cond_determined) {
check_expr(c, &operand, ws->cond);
if (operand.mode != Addressing_Invalid && !is_type_boolean(operand.type)) {
error(ws->cond, "Non-boolean condition in `when` statement");
error(ws->cond, "Non-boolean condition in 'when' statement");
}
if (operand.mode != Addressing_Constant) {
error(ws->cond, "Non-constant condition in `when` statement");
error(ws->cond, "Non-constant condition in 'when' statement");
}
ws->is_cond_determined = true;
@@ -3005,7 +3005,7 @@ bool collect_file_decls_from_when_stmt(Checker *c, AstNodeWhenStmt *ws) {
}
if (ws->body == nullptr || ws->body->kind != AstNode_BlockStmt) {
error(ws->cond, "Invalid body for `when` statement");
error(ws->cond, "Invalid body for 'when' statement");
} else {
if (ws->determined_cond) {
return collect_file_decls(c, ws->body->BlockStmt.stmts);
@@ -3016,7 +3016,7 @@ bool collect_file_decls_from_when_stmt(Checker *c, AstNodeWhenStmt *ws) {
case AstNode_WhenStmt:
return collect_file_decls_from_when_stmt(c, &ws->else_stmt->WhenStmt);
default:
error(ws->else_stmt, "Invalid `else` statement in `when` statement");
error(ws->else_stmt, "Invalid 'else' statement in 'when' statement");
break;
}
}
@@ -3124,17 +3124,17 @@ void check_import_entities(Checker *c) {
if (path.count == 1) {
ImportPathItem item = path[0];
String filename = fn(item);
error(item.decl, "Self importation of `%.*s`", LIT(filename));
error(item.decl, "Self importation of '%.*s'", LIT(filename));
} else if (path.count > 0) {
ImportPathItem item = path[path.count-1];
String filename = fn(item);
error(item.decl, "Cyclic importation of `%.*s`", LIT(filename));
error(item.decl, "Cyclic importation of '%.*s'", LIT(filename));
for (isize i = 0; i < path.count; i++) {
error(item.decl, "`%.*s` refers to", LIT(filename));
error(item.decl, "'%.*s' refers to", LIT(filename));
item = path[i];
filename = fn(item);
}
error(item.decl, "`%.*s`", LIT(filename));
error(item.decl, "'%.*s'", LIT(filename));
}
}
@@ -3287,12 +3287,12 @@ void calculate_global_init_order(Checker *c) {
if (path.count > 0) {
Entity *e = path[0];
error(e->token, "Cyclic initialization of `%.*s`", LIT(e->token.string));
error(e->token, "Cyclic initialization of '%.*s'", LIT(e->token.string));
for (isize i = path.count-1; i >= 0; i--) {
error(e->token, "\t`%.*s` refers to", LIT(e->token.string));
error(e->token, "\t'%.*s' refers to", LIT(e->token.string));
e = path[i];
}
error(e->token, "\t`%.*s`", LIT(e->token.string));
error(e->token, "\t'%.*s'", LIT(e->token.string));
}
}
@@ -3328,7 +3328,7 @@ void calculate_global_init_order(Checker *c) {
Entity *e = d->entities[j];
if (j == 0) gb_printf("\t");
if (j > 0) gb_printf(", ");
gb_printf("`%.*s` %td", LIT(e->token.string), e->order_in_src);
gb_printf("'%.*s' %td", LIT(e->token.string), e->order_in_src);
}
gb_printf("\n");
}
@@ -3365,7 +3365,7 @@ void check_parsed_files(Checker *c) {
check_import_entities(c);
check_all_global_entities(c);
init_preload(c); // NOTE(bill): This could be setup previously through the use of `type_info_of`
init_preload(c); // NOTE(bill): This could be setup previously through the use of 'type_info_of'
// Check procedure bodies
// NOTE(bill): Nested procedures bodies will be added to this "queue"
@@ -3458,7 +3458,7 @@ void check_parsed_files(Checker *c) {
token.pos.column = 1;
}
error(token, "Undefined entry point procedure `main`");
error(token, "Undefined entry point procedure 'main'");
}
}
}

View File

@@ -246,7 +246,7 @@ ExactValue exact_value_from_basic_literal(Token token) {
case Token_Imag: {
String str = token.string;
Rune last_rune = cast(Rune)str[str.len-1];
str.len--; // Ignore the `i|j|k`
str.len--; // Ignore the 'i|j|k'
f64 imag = float_from_string(str);
if (last_rune == 'i') {
@@ -344,7 +344,7 @@ ExactValue exact_value_make_imag(ExactValue v) {
case ExactValue_Float:
return exact_value_complex(0, v.value_float);
default:
GB_PANIC("Expected an integer or float type for `exact_value_make_imag`");
GB_PANIC("Expected an integer or float type for 'exact_value_make_imag'");
}
ExactValue r = {ExactValue_Invalid};
return r;

View File

@@ -93,7 +93,7 @@ struct irDefer {
irBlock * block;
union {
AstNode *stmt;
// NOTE(bill): `instr` will be copied every time to create a new one
// NOTE(bill): 'instr' will be copied every time to create a new one
irValue *instr;
};
};
@@ -2268,7 +2268,7 @@ irValue *ir_emit_arith(irProcedure *proc, TokenKind op, irValue *left, irValue *
case Token_AndNot: {
// NOTE(bill): x &~ y == x & (~y) == x & (y ~ -1)
// NOTE(bill): "not" `x` == `x` "xor" `-1`
// NOTE(bill): "not" 'x' == 'x' "xor" '-1'
irValue *neg = ir_add_module_constant(proc->module, type, exact_value_i64(-1));
op = Token_Xor;
right = ir_emit_arith(proc, op, right, neg, type);
@@ -2988,7 +2988,7 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
} else if (is_type_integer(dst)) {
ev = exact_value_to_integer(ev);
} else if (is_type_pointer(dst)) {
// IMPORTANT NOTE(bill): LLVM doesn't support pointer constants expect `null`
// IMPORTANT NOTE(bill): LLVM doesn't support pointer constants expect 'null'
irValue *i = ir_add_module_constant(proc->module, t_uintptr, ev);
return ir_emit(proc, ir_instr_conv(proc, irConv_inttoptr, i, t_uintptr, dst));
}
@@ -3137,7 +3137,7 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
}
}
// NOTE(bill): This has to be done before `Pointer <-> Pointer` as it's
// NOTE(bill): This has to be done before 'Pointer <-> Pointer' as it's
// subtype polymorphism casting
if (check_is_assignable_to_using_subtype(src_type, t)) {
Type *st = type_deref(src_type);
@@ -3281,7 +3281,7 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
gb_printf_err("Not Identical %s != %s\n", type_to_string(src), type_to_string(dst));
GB_PANIC("Invalid type conversion: `%s` to `%s` for procedure `%.*s`",
GB_PANIC("Invalid type conversion: '%s' to '%s' for procedure '%.*s'",
type_to_string(src_type), type_to_string(t),
LIT(proc->name));
@@ -3338,7 +3338,7 @@ irValue *ir_emit_transmute(irProcedure *proc, irValue *value, Type *t) {
i64 sz = type_size_of(m->allocator, src);
i64 dz = type_size_of(m->allocator, dst);
GB_ASSERT_MSG(sz == dz, "Invalid transmute conversion: `%s` to `%s`", type_to_string(src_type), type_to_string(t));
GB_ASSERT_MSG(sz == dz, "Invalid transmute conversion: '%s' to '%s'", type_to_string(src_type), type_to_string(t));
// NOTE(bill): Casting between an integer and a pointer cannot be done through a bitcast
if (is_type_uintptr(src) && is_type_pointer(dst)) {
@@ -3862,7 +3862,7 @@ void ir_gen_global_type_name(irModule *m, Entity *e, String name) {
#if 0
if (is_type_union(e->type)) {
Type *bt = base_type(e->type);
// NOTE(bill): Zeroth entry is null (for `match type` stmts)
// NOTE(bill): Zeroth entry is null (for 'match type' stmts)
for (isize j = 1; j < bt->Struct.variant_count; j++) {
ir_mangle_add_sub_type_name(m, bt->Struct.variants[j], name);
}
@@ -3923,7 +3923,7 @@ irValue *ir_emit_clamp(irProcedure *proc, Type *t, irValue *x, irValue *min, irV
irValue *ir_find_global_variable(irProcedure *proc, String name) {
irValue **value = map_get(&proc->module->members, hash_string(name));
GB_ASSERT_MSG(value != nullptr, "Unable to find global variable `%.*s`", LIT(name));
GB_ASSERT_MSG(value != nullptr, "Unable to find global variable '%.*s'", LIT(name));
return *value;
}
@@ -4298,7 +4298,7 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv
} else if (is_type_string(type)) {
ptr = ir_string_elem(proc, val);
} else {
GB_PANIC("Invalid type to `free`");
GB_PANIC("Invalid type to 'free'");
}
if (ptr == nullptr) {
@@ -4345,7 +4345,7 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv
args[1] = capacity;
return ir_emit_global_call(proc, "__dynamic_map_reserve", args, 2);
} else {
GB_PANIC("Unknown type for `reserve`");
GB_PANIC("Unknown type for 'reserve'");
}
break;
}
@@ -4372,7 +4372,7 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv
irValue *count_ptr = ir_emit_struct_ep(proc, ptr, 1);
ir_emit_store(proc, count_ptr, v_zero);
} else {
GB_PANIC("TODO(bill): ir clear for `%s`", type_to_string(t));
GB_PANIC("TODO(bill): ir clear for '%s'", type_to_string(t));
}
return nullptr;
break;
@@ -4778,7 +4778,7 @@ irValue *ir_build_expr(irProcedure *proc, AstNode *expr) {
GB_ASSERT_MSG(e != nullptr, "%s", expr_to_string(expr));
if (e->kind == Entity_Builtin) {
Token token = ast_node_token(expr);
GB_PANIC("TODO(bill): ir_build_single_expr Entity_Builtin `%.*s`\n"
GB_PANIC("TODO(bill): ir_build_single_expr Entity_Builtin '%.*s'\n"
"\t at %.*s(%td:%td)", LIT(builtin_procs[e->Builtin.id].name),
LIT(token.pos.file), token.pos.line, token.pos.column);
return nullptr;
@@ -5715,7 +5715,7 @@ irAddr ir_build_addr(irProcedure *proc, AstNode *expr) {
case_end;
case_ast_node(ce, CallExpr, expr);
// NOTE(bill): This is make sure you never need to have an `array_ev`
// NOTE(bill): This is make sure you never need to have an 'array_ev'
irValue *e = ir_build_expr(proc, expr);
irValue *v = ir_add_local_generated(proc, ir_type(e));
ir_emit_store(proc, v, e);
@@ -5772,7 +5772,7 @@ irAddr ir_build_addr(irProcedure *proc, AstNode *expr) {
case Type_Struct: {
// TODO(bill): "constant" `#raw_union`s are not initialized constantly at the moment.
// TODO(bill): "constant" '#raw_union's are not initialized constantly at the moment.
// NOTE(bill): This is due to the layout of the unions when printed to LLVM-IR
bool is_raw_union = is_type_raw_union(bt);
GB_ASSERT(is_type_struct(bt) || is_raw_union);
@@ -6235,7 +6235,7 @@ void ir_build_when_stmt(irProcedure *proc, AstNodeWhenStmt *ws) {
ir_build_when_stmt(proc, &ws->else_stmt->WhenStmt);
break;
default:
GB_PANIC("Invalid `else` statement in `when` statement");
GB_PANIC("Invalid 'else' statement in 'when' statement");
break;
}
}
@@ -6407,7 +6407,7 @@ void ir_build_range_string(irProcedure *proc, irValue *expr, Type *val_type,
void ir_build_range_interval(irProcedure *proc, AstNodeBinaryExpr *node, Type *val_type,
irValue **val_, irValue **idx_, irBlock **loop_, irBlock **done_) {
// TODO(bill): How should the behaviour work for lower and upper bounds checking for iteration?
// If `lower` is changed, should `val` do so or is that not typical behaviour?
// If 'lower' is changed, should 'val' do so or is that not typical behaviour?
irValue *lower = ir_build_expr(proc, node->left);
irValue *upper = nullptr;
@@ -7175,8 +7175,8 @@ void ir_build_stmt_internal(irProcedure *proc, AstNode *node) {
Type *parent_type = ir_type(parent);
bool is_parent_ptr = is_type_pointer(ir_type(parent));
MatchTypeKind match_type_kind = check_valid_type_match_type(ir_type(parent));
GB_ASSERT(match_type_kind != MatchType_Invalid);
SwitchTypeKind switch_type_kind = check_valid_type_switch_type(ir_type(parent));
GB_ASSERT(switch_type_kind != SwitchType_Invalid);
irValue *parent_value = parent;
@@ -7187,7 +7187,7 @@ void ir_build_stmt_internal(irProcedure *proc, AstNode *node) {
irValue *tag_index = nullptr;
irValue *union_data = nullptr;
if (match_type_kind == MatchType_Union) {
if (switch_type_kind == SwitchType_Union) {
ir_emit_comment(proc, str_lit("get union's tag"));
tag_index = ir_emit_load(proc, ir_emit_union_tag_ptr(proc, parent_ptr));
union_data = ir_emit_conv(proc, parent_ptr, t_rawptr);
@@ -7220,11 +7220,11 @@ void ir_build_stmt_internal(irProcedure *proc, AstNode *node) {
next = ir_new_block(proc, nullptr, "typeswitch.next");
case_type = type_of_expr(proc->module->info, cc->list[type_index]);
irValue *cond = nullptr;
if (match_type_kind == MatchType_Union) {
if (switch_type_kind == SwitchType_Union) {
Type *ut = base_type(type_deref(parent_type));
irValue *variant_tag = ir_const_union_tag(proc->module->allocator, ut, case_type);
cond = ir_emit_comp(proc, Token_CmpEq, tag_index, variant_tag);
} else if (match_type_kind == MatchType_Any) {
} else if (switch_type_kind == SwitchType_Any) {
irValue *any_ti = ir_emit_load(proc, ir_emit_struct_ep(proc, parent_ptr, 1));
irValue *case_ti = ir_type_info(proc, case_type);
cond = ir_emit_comp(proc, Token_CmpEq, any_ti, case_ti);
@@ -7250,9 +7250,9 @@ void ir_build_stmt_internal(irProcedure *proc, AstNode *node) {
}
GB_ASSERT_MSG(is_type_pointer(ct), "%s", type_to_string(ct));
irValue *data = nullptr;
if (match_type_kind == MatchType_Union) {
if (switch_type_kind == SwitchType_Union) {
data = union_data;
} else if (match_type_kind == MatchType_Any) {
} else if (switch_type_kind == SwitchType_Any) {
irValue *any_data = ir_emit_load(proc, ir_emit_struct_ep(proc, parent_ptr, 0));
data = any_data;
}
@@ -8713,7 +8713,7 @@ void ir_gen_tree(irGen *s) {
Type *t = type_deref(ir_type(var->var));
if (is_type_any(t)) {
// NOTE(bill): Edge case for `any` type
// NOTE(bill): Edge case for 'any' type
Type *var_type = default_type(ir_type(var->init));
irValue *g = ir_add_global_generated(proc->module, var_type, var->init);
ir_emit_store(proc, g, var->init);

View File

@@ -19,7 +19,7 @@
#include "ir_print.cpp"
#if defined(GB_SYSTEM_WINDOWS)
// NOTE(bill): `name` is used in debugging and profiling modes
// NOTE(bill): 'name' is used in debugging and profiling modes
i32 system_exec_command_line_app(char *name, bool is_silent, char *fmt, ...) {
STARTUPINFOW start_info = {gb_size_of(STARTUPINFOW)};
PROCESS_INFORMATION pi = {0};
@@ -275,7 +275,7 @@ bool parse_build_flags(Array<String> args) {
if (bf.name == name) {
found = true;
if (set_flags[bf.kind]) {
gb_printf_err("Previous flag set: `%.*s`\n", LIT(name));
gb_printf_err("Previous flag set: '%.*s'\n", LIT(name));
bad_flags = true;
} else {
ExactValue value = {};
@@ -284,11 +284,11 @@ bool parse_build_flags(Array<String> args) {
if (param.len == 0) {
ok = true;
} else {
gb_printf_err("Flag `%.*s` was not expecting a parameter `%.*s`\n", LIT(name), LIT(param));
gb_printf_err("Flag '%.*s' was not expecting a parameter '%.*s'\n", LIT(name), LIT(param));
bad_flags = true;
}
} else if (param.len == 0) {
gb_printf_err("Flag missing for `%.*s`\n", LIT(name));
gb_printf_err("Flag missing for '%.*s'\n", LIT(name));
bad_flags = true;
} else {
ok = true;
@@ -320,7 +320,7 @@ bool parse_build_flags(Array<String> args) {
} else if (param == "0") {
value = exact_value_bool(false);
} else {
gb_printf_err("Invalid flag parameter for `%.*s` = `%.*s`\n", LIT(name), LIT(param));
gb_printf_err("Invalid flag parameter for '%.*s' = '%.*s'\n", LIT(name), LIT(param));
}
} break;
case BuildFlagParam_Integer:
@@ -408,20 +408,20 @@ bool parse_build_flags(Array<String> args) {
}
}
if (eq_pos < 0) {
gb_printf_err("Expected `name=path`, got `%.*s`\n", LIT(param));
gb_printf_err("Expected 'name=path', got '%.*s'\n", LIT(param));
bad_flags = true;
break;
}
String name = substring(str, 0, eq_pos);
String path = substring(str, eq_pos+1, str.len);
if (name.len == 0 || path.len == 0) {
gb_printf_err("Expected `name=path`, got `%.*s`\n", LIT(param));
gb_printf_err("Expected 'name=path', got '%.*s'\n", LIT(param));
bad_flags = true;
break;
}
if (!string_is_valid_identifier(name)) {
gb_printf_err("Library collection name `%.*s` must be a valid identifier\n", LIT(name));
gb_printf_err("Library collection name '%.*s' must be a valid identifier\n", LIT(name));
bad_flags = true;
break;
}
@@ -433,7 +433,7 @@ bool parse_build_flags(Array<String> args) {
}
if (name == "system") {
gb_printf_err("Library collection name `system` is reserved\n");
gb_printf_err("Library collection name 'system' is reserved\n");
bad_flags = true;
break;
}
@@ -441,7 +441,7 @@ bool parse_build_flags(Array<String> args) {
String prev_path = {};
bool found = find_library_collection_path(name, &prev_path);
if (found) {
gb_printf_err("Library collection `%.*s` already exists with path `%.*s`\n", LIT(name), LIT(prev_path));
gb_printf_err("Library collection '%.*s' already exists with path '%.*s'\n", LIT(name), LIT(prev_path));
bad_flags = true;
break;
}
@@ -449,7 +449,7 @@ bool parse_build_flags(Array<String> args) {
gbAllocator a = heap_allocator();
String fullpath = path_to_fullpath(a, path);
if (!path_is_directory(fullpath)) {
gb_printf_err("Library collection `%.*s` path must be a directory, got `%.*s`\n", LIT(name), LIT(fullpath));
gb_printf_err("Library collection '%.*s' path must be a directory, got '%.*s'\n", LIT(name), LIT(fullpath));
gb_free(a, fullpath.text);
bad_flags = true;
break;
@@ -470,7 +470,7 @@ bool parse_build_flags(Array<String> args) {
}
}
if (!found) {
gb_printf_err("Unknown flag: `%.*s`\n", LIT(name));
gb_printf_err("Unknown flag: '%.*s'\n", LIT(name));
bad_flags = true;
}
}
@@ -552,7 +552,7 @@ int main(int arg_count, char **arg_ptr) {
init_global_error_collector();
array_init(&library_collections, heap_allocator());
// NOTE(bill): `core` cannot be (re)defined by the user
// NOTE(bill): 'core' cannot be (re)defined by the user
add_library_collection(str_lit("core"), get_fullpath_relative(heap_allocator(), odin_root_dir(), str_lit("core")));
Array<String> args = setup_args(arg_count, arg_ptr);
@@ -606,7 +606,7 @@ int main(int arg_count, char **arg_ptr) {
}
// NOTE(bill): add `shared` directory if it is not already set
// NOTE(bill): add 'shared' directory if it is not already set
if (!find_library_collection_path(str_lit("shared"), nullptr)) {
add_library_collection(str_lit("shared"),
get_fullpath_relative(heap_allocator(), odin_root_dir(), str_lit("shared")));
@@ -717,7 +717,7 @@ int main(int arg_count, char **arg_ptr) {
#if defined(GB_SYSTEM_OSX)
// This sets a requirement of Mountain Lion and up, but the compiler doesn't work without this limit.
// NOTE: If you change this (although this minimum is as low as you can go with Odin working)
// make sure to also change the `macosx_version_min` param passed to `llc`
// make sure to also change the 'macosx_version_min' param passed to 'llc'
"-mtriple=x86_64-apple-macosx10.8 "
#endif
"",
@@ -844,17 +844,17 @@ int main(int arg_count, char **arg_ptr) {
len = gb_snprintf(lib_str_buf, gb_size_of(lib_str_buf), " -l%.*s ", LIT(lib));
}
#else
// NOTE(vassvik): static libraries (.a files) in linux can be linked to directly using the full path,
// since those are statically linked to at link time. shared libraries (.so) has to be
// NOTE(vassvik): static libraries (.a files) in linux can be linked to directly using the full path,
// since those are statically linked to at link time. shared libraries (.so) has to be
// available at runtime wherever the executable is run, so we make require those to be
// local to the executable (unless the system collection is used, in which case we search
// the system library paths for the library file).
// the system library paths for the library file).
if (string_has_extension(lib, str_lit("a"))) {
// static libs, absolute full path relative to the file in which the lib was imported from
isize len = gb_snprintf(lib_str_buf, gb_size_of(lib_str_buf), " -l:%.*s ", LIT(lib));
} else if (string_has_extension(lib, str_lit("so"))) {
// dynamic lib, relative path to executable
// NOTE(vassvik): it is the user's responsibility to make sure the shared library files are visible
// NOTE(vassvik): it is the user's responsibility to make sure the shared library files are visible
// at runtimeto the executable
isize len = gb_snprintf(lib_str_buf, gb_size_of(lib_str_buf), " -l:%s/%.*s ", cwd, LIT(lib));
} else {
@@ -902,7 +902,7 @@ int main(int arg_count, char **arg_ptr) {
#if defined(GB_SYSTEM_OSX)
// This sets a requirement of Mountain Lion and up, but the compiler doesn't work without this limit.
// NOTE: If you change this (although this minimum is as low as you can go with Odin working)
// make sure to also change the `mtriple` param passed to `opt`
// make sure to also change the 'mtriple' param passed to 'opt'
" -macosx_version_min 10.8.0 "
// This points the linker to where the entry point is
" -e _main "

View File

@@ -57,7 +57,7 @@ struct AstFile {
Array<AstNode *> decls;
ImportedFileKind file_kind;
bool is_global_scope;
Array<AstNode *> imports_and_exports; // `import` `using import` `export`
Array<AstNode *> imports_and_exports; // 'import' 'using import' 'export'
AstNode * curr_proc;
@@ -1004,11 +1004,11 @@ AstNode *ast_binary_expr(AstFile *f, Token op, AstNode *left, AstNode *right) {
AstNode *result = make_ast_node(f, AstNode_BinaryExpr);
if (left == nullptr) {
syntax_error(op, "No lhs expression for binary expression `%.*s`", LIT(op.string));
syntax_error(op, "No lhs expression for binary expression '%.*s'", LIT(op.string));
left = ast_bad_expr(f, op, op);
}
if (right == nullptr) {
syntax_error(op, "No rhs expression for binary expression `%.*s`", LIT(op.string));
syntax_error(op, "No rhs expression for binary expression '%.*s'", LIT(op.string));
right = ast_bad_expr(f, op, op);
}
@@ -1706,7 +1706,7 @@ Token expect_token(AstFile *f, TokenKind kind) {
if (prev.kind != kind) {
String c = token_strings[kind];
String p = token_strings[prev.kind];
syntax_error(f->curr_token, "Expected `%.*s`, got `%.*s`", LIT(c), LIT(p));
syntax_error(f->curr_token, "Expected '%.*s', got '%.*s'", LIT(c), LIT(p));
if (prev.kind == Token_EOF) {
gb_exit(1);
}
@@ -1720,7 +1720,7 @@ Token expect_token_after(AstFile *f, TokenKind kind, char *msg) {
Token prev = f->curr_token;
if (prev.kind != kind) {
String p = token_strings[prev.kind];
syntax_error(f->curr_token, "Expected `%.*s` after %s, got `%.*s`",
syntax_error(f->curr_token, "Expected '%.*s' after %s, got '%.*s'",
LIT(token_strings[kind]),
msg,
LIT(p));
@@ -1733,10 +1733,10 @@ Token expect_token_after(AstFile *f, TokenKind kind, char *msg) {
Token expect_operator(AstFile *f) {
Token prev = f->curr_token;
if (!gb_is_between(prev.kind, Token__OperatorBegin+1, Token__OperatorEnd-1)) {
syntax_error(f->curr_token, "Expected an operator, got `%.*s`",
syntax_error(f->curr_token, "Expected an operator, got '%.*s'",
LIT(token_strings[prev.kind]));
} else if (!f->allow_range && (prev.kind == Token_Ellipsis || prev.kind == Token_HalfClosed)) {
syntax_error(f->curr_token, "Expected an non-range operator, got `%.*s`",
syntax_error(f->curr_token, "Expected an non-range operator, got '%.*s'",
LIT(token_strings[prev.kind]));
}
advance_token(f);
@@ -1746,7 +1746,7 @@ Token expect_operator(AstFile *f) {
Token expect_keyword(AstFile *f) {
Token prev = f->curr_token;
if (!gb_is_between(prev.kind, Token__KeywordBegin+1, Token__KeywordEnd-1)) {
syntax_error(f->curr_token, "Expected a keyword, got `%.*s`",
syntax_error(f->curr_token, "Expected a keyword, got '%.*s'",
LIT(token_strings[prev.kind]));
}
advance_token(f);
@@ -1837,7 +1837,7 @@ Token expect_closing(AstFile *f, TokenKind kind, String context) {
if (f->curr_token.kind != kind &&
f->curr_token.kind == Token_Semicolon &&
f->curr_token.string == "\n") {
syntax_error(f->curr_token, "Missing `,` before newline in %.*s", LIT(context));
syntax_error(f->curr_token, "Missing ',' before newline in %.*s", LIT(context));
advance_token(f);
}
return expect_token(f, kind);
@@ -1926,10 +1926,10 @@ void expect_semicolon(AstFile *f, AstNode *s) {
return;
}
String node_string = ast_node_strings[s->kind];
syntax_error(prev_token, "Expected `;` after %.*s, got %.*s",
syntax_error(prev_token, "Expected ';' after %.*s, got %.*s",
LIT(node_string), LIT(token_strings[prev_token.kind]));
} else {
syntax_error(prev_token, "Expected `;`");
syntax_error(prev_token, "Expected ';'");
}
fix_advance_to_next_stmt(f);
}
@@ -2125,7 +2125,7 @@ AstNode *convert_stmt_to_expr(AstFile *f, AstNode *statement, String kind) {
return statement->ExprStmt.expr;
}
syntax_error(f->curr_token, "Expected `%.*s`, found a simple statement.", LIT(kind));
syntax_error(f->curr_token, "Expected '%.*s', found a simple statement.", LIT(kind));
Token end = f->curr_token;
if (f->tokens.count < f->curr_token_index) {
end = f->tokens[f->curr_token_index+1];
@@ -2264,7 +2264,7 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
if (pi != ProcInlining_none) {
if (expr->ProcLit.inlining != ProcInlining_none &&
expr->ProcLit.inlining != pi) {
syntax_error(expr, "You cannot apply both `inline` and `no_inline` to a procedure literal");
syntax_error(expr, "You cannot apply both 'inline' and 'no_inline' to a procedure literal");
}
expr->ProcLit.inlining = pi;
}
@@ -2409,41 +2409,41 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
Token tag = expect_token_after(f, Token_Ident, "#");
if (tag.string == "packed") {
if (is_packed) {
syntax_error(tag, "Duplicate struct tag `#%.*s`", LIT(tag.string));
syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
}
is_packed = true;
} else if (tag.string == "ordered") {
if (is_ordered) {
syntax_error(tag, "Duplicate struct tag `#%.*s`", LIT(tag.string));
syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
}
is_ordered = true;
} else if (tag.string == "align") {
if (align) {
syntax_error(tag, "Duplicate struct tag `#%.*s`", LIT(tag.string));
syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
}
align = parse_expr(f, true);
} else if (tag.string == "raw_union") {
if (is_raw_union) {
syntax_error(tag, "Duplicate struct tag `#%.*s`", LIT(tag.string));
syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
}
is_raw_union = true;
} else {
syntax_error(tag, "Invalid struct tag `#%.*s`", LIT(tag.string));
syntax_error(tag, "Invalid struct tag '#%.*s'", LIT(tag.string));
}
}
f->expr_level = prev_level;
if (is_packed && is_ordered) {
syntax_error(token, "`#ordered` is not needed with `#packed` which implies ordering");
syntax_error(token, "'#ordered' is not needed with '#packed' which implies ordering");
}
if (is_raw_union && is_packed) {
is_packed = false;
syntax_error(token, "`#raw_union` cannot also be `#packed`");
syntax_error(token, "'#raw_union' cannot also be '#packed'");
}
if (is_raw_union && is_ordered) {
is_ordered = false;
syntax_error(token, "`#raw_union` cannot also be `#ordered`");
syntax_error(token, "'#raw_union' cannot also be '#ordered'");
}
Token open = expect_token_after(f, Token_OpenBrace, "struct");
@@ -2475,11 +2475,11 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
Token tag = expect_token_after(f, Token_Ident, "#");
if (tag.string == "align") {
if (align) {
syntax_error(tag, "Duplicate union tag `#%.*s`", LIT(tag.string));
syntax_error(tag, "Duplicate union tag '#%.*s'", LIT(tag.string));
}
align = parse_expr(f, true);
} else {
syntax_error(tag, "Invalid union tag `#%.*s`", LIT(tag.string));
syntax_error(tag, "Invalid union tag '#%.*s'", LIT(tag.string));
}
}
@@ -2527,11 +2527,11 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
Token tag = expect_token_after(f, Token_Ident, "#");
if (tag.string == "align") {
if (align) {
syntax_error(tag, "Duplicate bit_field tag `#%.*s`", LIT(tag.string));
syntax_error(tag, "Duplicate bit_field tag '#%.*s'", LIT(tag.string));
}
align = parse_expr(f, true);
} else {
syntax_error(tag, "Invalid bit_field tag `#%.*s`", LIT(tag.string));
syntax_error(tag, "Invalid bit_field tag '#%.*s'", LIT(tag.string));
}
}
@@ -2624,7 +2624,7 @@ AstNode *parse_call_expr(AstFile *f, AstNode *operand) {
Token eq = expect_token(f, Token_Eq);
if (prefix_ellipsis) {
syntax_error(ellipsis, "`...` must be applied to value rather than the field name");
syntax_error(ellipsis, "'...' must be applied to value rather than the field name");
}
AstNode *value = parse_value(f);
@@ -3259,7 +3259,7 @@ AstNode *parse_proc_type(AstFile *f, Token proc_token) {
Token token = expect_token(f, Token_String);
auto c = string_to_calling_convention(token.string);
if (c == ProcCC_Invalid) {
syntax_error(token, "Unknown procedure calling convention: `%.*s`\n", LIT(token.string));
syntax_error(token, "Unknown procedure calling convention: '%.*s'\n", LIT(token.string));
} else {
cc = c;
}
@@ -3307,7 +3307,7 @@ AstNode *parse_var_type(AstFile *f, bool allow_ellipsis, bool allow_type_token)
Token tok = advance_token(f);
AstNode *type = parse_type_or_ident(f);
if (type == nullptr) {
syntax_error(tok, "variadic field missing type after `...`");
syntax_error(tok, "variadic field missing type after '...'");
type = ast_bad_expr(f, tok, f->curr_token);
}
return ast_ellipsis(f, tok, type);
@@ -3382,7 +3382,7 @@ u32 parse_field_prefixes(AstFile *f) {
break;
}
if (kind == FieldPrefix_Unknown) {
syntax_error(f->curr_token, "Unknown prefix kind `#%.*s`", LIT(f->curr_token.string));
syntax_error(f->curr_token, "Unknown prefix kind '#%.*s'", LIT(f->curr_token.string));
advance_token(f);
continue;
}
@@ -3394,10 +3394,10 @@ u32 parse_field_prefixes(AstFile *f) {
case FieldPrefix_const: const_count += 1; advance_token(f); break;
}
}
if (using_count > 1) syntax_error(f->curr_token, "Multiple `using` in this field list");
if (no_alias_count > 1) syntax_error(f->curr_token, "Multiple `#no_alias` in this field list");
if (c_vararg_count > 1) syntax_error(f->curr_token, "Multiple `#c_vararg` in this field list");
if (const_count > 1) syntax_error(f->curr_token, "Multiple `#const` in this field list");
if (using_count > 1) syntax_error(f->curr_token, "Multiple 'using' in this field list");
if (no_alias_count > 1) syntax_error(f->curr_token, "Multiple '#no_alias' in this field list");
if (c_vararg_count > 1) syntax_error(f->curr_token, "Multiple '#c_vararg' in this field list");
if (const_count > 1) syntax_error(f->curr_token, "Multiple '#const' in this field list");
u32 field_flags = 0;
@@ -3410,24 +3410,24 @@ u32 parse_field_prefixes(AstFile *f) {
u32 check_field_prefixes(AstFile *f, isize name_count, u32 allowed_flags, u32 set_flags) {
if (name_count > 1 && (set_flags&FieldFlag_using)) {
syntax_error(f->curr_token, "Cannot apply `using` to more than one of the same type");
syntax_error(f->curr_token, "Cannot apply 'using' to more than one of the same type");
set_flags &= ~FieldFlag_using;
}
if ((allowed_flags&FieldFlag_using) == 0 && (set_flags&FieldFlag_using)) {
syntax_error(f->curr_token, "`using` is not allowed within this field list");
syntax_error(f->curr_token, "'using' is not allowed within this field list");
set_flags &= ~FieldFlag_using;
}
if ((allowed_flags&FieldFlag_no_alias) == 0 && (set_flags&FieldFlag_no_alias)) {
syntax_error(f->curr_token, "`#no_alias` is not allowed within this field list");
syntax_error(f->curr_token, "'#no_alias' is not allowed within this field list");
set_flags &= ~FieldFlag_no_alias;
}
if ((allowed_flags&FieldFlag_c_vararg) == 0 && (set_flags&FieldFlag_c_vararg)) {
syntax_error(f->curr_token, "`#c_vararg` is not allowed within this field list");
syntax_error(f->curr_token, "'#c_vararg' is not allowed within this field list");
set_flags &= ~FieldFlag_c_vararg;
}
if ((allowed_flags&FieldFlag_const) == 0 && (set_flags&FieldFlag_const)) {
syntax_error(f->curr_token, "`$` is not allowed within this field list");
syntax_error(f->curr_token, "'$' is not allowed within this field list");
set_flags &= ~FieldFlag_const;
}
return set_flags;
@@ -3795,28 +3795,28 @@ AstNode *parse_type_or_ident(AstFile *f) {
Token tag = expect_token_after(f, Token_Ident, "#");
if (tag.string == "packed") {
if (is_packed) {
syntax_error(tag, "Duplicate struct tag `#%.*s`", LIT(tag.string));
syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
}
is_packed = true;
} else if (tag.string == "ordered") {
if (is_ordered) {
syntax_error(tag, "Duplicate struct tag `#%.*s`", LIT(tag.string));
syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
}
is_ordered = true;
} else if (tag.string == "align") {
if (align) {
syntax_error(tag, "Duplicate struct tag `#%.*s`", LIT(tag.string));
syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
}
align = parse_expr(f, true);
} else {
syntax_error(tag, "Invalid struct tag `#%.*s`", LIT(tag.string));
syntax_error(tag, "Invalid struct tag '#%.*s'", LIT(tag.string));
}
}
f->expr_level = prev_level;
if (is_packed && is_ordered) {
syntax_error(token, "`#ordered` is not needed with `#packed` which implies ordering");
syntax_error(token, "'#ordered' is not needed with '#packed' which implies ordering");
}
Token open = expect_token_after(f, Token_OpenBrace, "struct");
@@ -3904,11 +3904,11 @@ AstNode *parse_type_or_ident(AstFile *f) {
Token tag = expect_token_after(f, Token_Ident, "#");
if (tag.string == "align") {
if (align) {
syntax_error(tag, "Duplicate bit_field tag `#%.*s`", LIT(tag.string));
syntax_error(tag, "Duplicate bit_field tag '#%.*s'", LIT(tag.string));
}
align = parse_expr(f, true);
} else {
syntax_error(tag, "Invalid bit_field tag `#%.*s`", LIT(tag.string));
syntax_error(tag, "Invalid bit_field tag '#%.*s'", LIT(tag.string));
}
}
@@ -4329,7 +4329,7 @@ AstNode *parse_defer_stmt(AstFile *f) {
AstNode *stmt = parse_stmt(f);
switch (stmt->kind) {
case AstNode_EmptyStmt:
syntax_error(token, "Empty statement after defer (e.g. `;`)");
syntax_error(token, "Empty statement after defer (e.g. ';')");
break;
case AstNode_DeferStmt:
syntax_error(token, "You cannot defer a defer statement");
@@ -4385,14 +4385,14 @@ AstNode *parse_import_decl(AstFile *f, bool is_using) {
}
if (!is_using && is_blank_ident(import_name)) {
syntax_error(import_name, "Illegal import name: `_`");
syntax_error(import_name, "Illegal import name: '_'");
}
Token file_path = expect_token_after(f, Token_String, "import");
AstNode *s = nullptr;
if (f->curr_proc != nullptr) {
syntax_error(import_name, "You cannot use `import` within a procedure. This must be done at the file scope");
syntax_error(import_name, "You cannot use 'import' within a procedure. This must be done at the file scope");
s = ast_bad_decl(f, import_name, file_path);
} else {
s = ast_import_decl(f, token, is_using, file_path, import_name, docs, f->line_comment);
@@ -4408,7 +4408,7 @@ AstNode *parse_export_decl(AstFile *f) {
Token file_path = expect_token_after(f, Token_String, "export");
AstNode *s = nullptr;
if (f->curr_proc != nullptr) {
syntax_error(token, "You cannot use `export` within a procedure. This must be done at the file scope");
syntax_error(token, "You cannot use 'export' within a procedure. This must be done at the file scope");
s = ast_bad_decl(f, token, file_path);
} else {
s = ast_export_decl(f, token, file_path, docs, f->line_comment);
@@ -4439,7 +4439,7 @@ AstNode *parse_foreign_decl(AstFile *f) {
break;
}
if (is_blank_ident(lib_name)) {
syntax_error(lib_name, "Illegal foreign_library name: `_`");
syntax_error(lib_name, "Illegal foreign_library name: '_'");
}
Token file_path = expect_token(f, Token_String);
AstNode *s = nullptr;
@@ -4545,7 +4545,7 @@ AstNode *parse_stmt(AstFile *f) {
AstNode *decl = nullptr;
Array<AstNode *> list = parse_lhs_expr_list(f);
if (list.count == 0) {
syntax_error(token, "Illegal use of `using` statement");
syntax_error(token, "Illegal use of 'using' statement");
expect_semicolon(f, nullptr);
return ast_bad_stmt(f, token, f->curr_token);
}
@@ -4558,14 +4558,14 @@ AstNode *parse_stmt(AstFile *f) {
if (decl != nullptr && decl->kind == AstNode_ValueDecl) {
if (!decl->ValueDecl.is_mutable) {
syntax_error(token, "`using` may only be applied to variable declarations");
syntax_error(token, "'using' may only be applied to variable declarations");
return decl;
}
decl->ValueDecl.is_using = true;
return decl;
}
syntax_error(token, "Illegal use of `using` statement");
syntax_error(token, "Illegal use of 'using' statement");
return ast_bad_stmt(f, token, f->curr_token);
} break;
@@ -4644,10 +4644,10 @@ AstNode *parse_stmt(AstFile *f) {
}
if (tag == "include") {
syntax_error(token, "#include is not a valid import declaration kind. Did you mean `import`?");
syntax_error(token, "#include is not a valid import declaration kind. Did you mean 'import'?");
s = ast_bad_stmt(f, token, f->curr_token);
} else {
syntax_error(token, "Unknown tag directive used: `%.*s`", LIT(tag));
syntax_error(token, "Unknown tag directive used: '%.*s'", LIT(tag));
s = ast_bad_stmt(f, token, f->curr_token);
}
@@ -4666,7 +4666,7 @@ AstNode *parse_stmt(AstFile *f) {
}
syntax_error(token,
"Expected a statement, got `%.*s`",
"Expected a statement, got '%.*s'",
LIT(token_strings[token.kind]));
fix_advance_to_next_stmt(f);
return ast_bad_stmt(f, token, f->curr_token);
@@ -4886,7 +4886,7 @@ bool determine_path_from_string(Parser *p, AstNode *node, String base_dir, Strin
}
if (!is_import_path_valid(file_str)) {
syntax_error(node, "Invalid import path: `%.*s`", LIT(file_str));
syntax_error(node, "Invalid import path: '%.*s'", LIT(file_str));
return false;
}
@@ -4901,7 +4901,7 @@ bool determine_path_from_string(Parser *p, AstNode *node, String base_dir, Strin
if (collection_name.len > 0) {
if (collection_name == "system") {
if (node->kind != AstNode_ForeignImportDecl) {
syntax_error(node, "The library collection `system` is restrict for `foreign_library`");
syntax_error(node, "The library collection 'system' is restrict for 'foreign_library'");
return false;
} else {
*path = file_str;
@@ -4909,7 +4909,7 @@ bool determine_path_from_string(Parser *p, AstNode *node, String base_dir, Strin
}
} else if (!find_library_collection_path(collection_name, &base_dir)) {
// NOTE(bill): It's a naughty name
syntax_error(node, "Unknown library collection: `%.*s`", LIT(collection_name));
syntax_error(node, "Unknown library collection: '%.*s'", LIT(collection_name));
return false;
}
} else {
@@ -5071,7 +5071,7 @@ ParseFileError parse_import(Parser *p, ImportedFile imported_file) {
gb_printf_err("Failed to parse file: %.*s\n\t", LIT(import_rel_path));
switch (err) {
case ParseFile_WrongExtension:
gb_printf_err("Invalid file extension: File must have the extension `.odin`");
gb_printf_err("Invalid file extension: File must have the extension '.odin'");
break;
case ParseFile_InvalidFile:
gb_printf_err("Invalid file or cannot be found");
@@ -5080,7 +5080,7 @@ ParseFileError parse_import(Parser *p, ImportedFile imported_file) {
gb_printf_err("File permissions problem");
break;
case ParseFile_NotFound:
gb_printf_err("File cannot be found (`%.*s`)", LIT(import_path));
gb_printf_err("File cannot be found ('%.*s')", LIT(import_path));
break;
case ParseFile_InvalidToken:
gb_printf_err("Invalid token found in file at (%td:%td)", err_pos.line, err_pos.column);