List of known bugs:
-[ ] Using an auto-cast on an argument when calling an overloaded proc leads
+[X] Using an auto-cast on an argument when calling an overloaded proc leads
to an unexpected error. Take the following example:
```
overloaded :: proc {
if (type->Basic.size == 8) {
// TODO(Brendan): Check these boundary conditions
if (bh_abs(num->value.l) >= (1ull << 52)) {
- onyx_report_error(num->token->pos, "Integer '%l' does not fit in 32-bit float exactly.", num->value.l);
+ onyx_report_error(num->token->pos, "Integer '%l' does not fit in 64-bit float exactly.", num->value.l);
return 0;
}
// If the node is an auto cast, we convert it to a cast node which will reports errors if
// the cast is illegal in the code generation.
((AstUnaryOp *) node)->type = type;
- ((AstUnaryOp *) node)->operation = Unary_Op_Cast;
+ // ((AstUnaryOp *) node)->operation = Unary_Op_Cast;
return 1;
}
else if (node->kind == Ast_Kind_NumLit) {
TypeBasic* type = &unop->type->Basic;
- if (type->kind == Basic_Kind_I32 || type->kind == Basic_Kind_U32
- || type->kind == Basic_Kind_I16 || type->kind == Basic_Kind_U16
- || type->kind == Basic_Kind_I8 || type->kind == Basic_Kind_U8) {
+ if (type->kind == Basic_Kind_I8 || type->kind == Basic_Kind_U8) {
+ WID(WI_I32_CONST, 0xff);
+ WI(WI_I32_XOR);
+ }
+ else if (type->kind == Basic_Kind_I16 || type->kind == Basic_Kind_U16) {
+ WID(WI_I32_CONST, 0xffff);
+ WI(WI_I32_XOR);
+ }
+ else if (type->kind == Basic_Kind_I32 || type->kind == Basic_Kind_U32) {
WID(WI_I32_CONST, 0xffffffff);
WI(WI_I32_XOR);
-
}
else if (type->kind == Basic_Kind_I64 || type->kind == Basic_Kind_U64) {
WIL(WI_I64_CONST, 0xffffffffffffffff);
case Unary_Op_Cast: emit_cast(mod, &code, unop); break;
// NOTE: Any remaining auto casts can be ignored since it means that a cast was not necessary. - brendanfh 2020/09/19
- case Unary_Op_Auto_Cast: emit_expression(mod, &code, unop->expr); break;
+ case Unary_Op_Auto_Cast: emit_cast(mod, &code, unop); break;
}
*pcode = code;
--- /dev/null
+Called i32, i32
+Called f32, str
--- /dev/null
+#include_file "core/std/js"
+
+use package core
+
+overloaded :: proc {
+ proc (x: f32, y: str) do println("Called f32, str"); ,
+ proc (x: i32, y: i32) do println("Called i32, i32"); ,
+}
+
+main :: proc (args: [] cstr) {
+ x: i32 = 1234;
+ overloaded(~~x, 4);
+
+ y: i32 = 1234;
+ overloaded(~~x, "Test");
+}