mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Improve foreign variable fuzzy type checking
This commit is contained in:
@@ -4,9 +4,10 @@ package runtime
|
|||||||
|
|
||||||
foreign import libc "system:c"
|
foreign import libc "system:c"
|
||||||
|
|
||||||
|
@(default_calling_convention="c")
|
||||||
foreign libc {
|
foreign libc {
|
||||||
@(link_name="write")
|
@(link_name="write")
|
||||||
_unix_write :: proc(fd: uintptr, buf: rawptr, size: int) -> int ---
|
_unix_write :: proc(fd: i32, buf: rawptr, size: int) -> int ---
|
||||||
|
|
||||||
__error :: proc() -> ^i32 ---
|
__error :: proc() -> ^i32 ---
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ package runtime
|
|||||||
|
|
||||||
foreign import libc "system:System.framework"
|
foreign import libc "system:System.framework"
|
||||||
|
|
||||||
|
@(default_calling_convention="c")
|
||||||
foreign libc {
|
foreign libc {
|
||||||
@(link_name="__stderrp")
|
@(link_name="__stderrp")
|
||||||
_stderr: rawptr
|
_stderr: rawptr
|
||||||
|
|||||||
+2
-2
@@ -1143,7 +1143,7 @@ gb_internal void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
|
|||||||
"\tat %s",
|
"\tat %s",
|
||||||
LIT(name), token_pos_to_string(pos));
|
LIT(name), token_pos_to_string(pos));
|
||||||
}
|
}
|
||||||
} else if (!are_types_identical(this_type, other_type)) {
|
} else if (!signature_parameter_similar_enough(this_type, other_type)) {
|
||||||
error(d->proc_lit,
|
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",
|
"\tat %s",
|
||||||
@@ -1284,7 +1284,7 @@ gb_internal void check_global_variable_decl(CheckerContext *ctx, Entity *&e, Ast
|
|||||||
TokenPos pos = f->token.pos;
|
TokenPos pos = f->token.pos;
|
||||||
Type *this_type = base_type(e->type);
|
Type *this_type = base_type(e->type);
|
||||||
Type *other_type = base_type(f->type);
|
Type *other_type = base_type(f->type);
|
||||||
if (!are_types_identical(this_type, other_type)) {
|
if (!signature_parameter_similar_enough(this_type, other_type)) {
|
||||||
error(e->token,
|
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",
|
"\tat %s",
|
||||||
|
|||||||
+1
-1
@@ -1934,7 +1934,7 @@ gb_internal void check_value_decl_stmt(CheckerContext *ctx, Ast *node, u32 mod_f
|
|||||||
TokenPos pos = f->token.pos;
|
TokenPos pos = f->token.pos;
|
||||||
Type *this_type = base_type(e->type);
|
Type *this_type = base_type(e->type);
|
||||||
Type *other_type = base_type(f->type);
|
Type *other_type = base_type(f->type);
|
||||||
if (!are_types_identical(this_type, other_type)) {
|
if (!signature_parameter_similar_enough(this_type, other_type)) {
|
||||||
error(e->token,
|
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",
|
"\tat %s",
|
||||||
|
|||||||
Reference in New Issue
Block a user