List of known bugs:
+[ ] macros cannot use 'use'.
+
+ Vec2 :: struct { x, y : f32; }
+
+ foo :: macro (use v: Vec2) {
+ println(x); // Doesn't work
+ }
+
[X] macros are not allowed at the expression level. This is not necessarily a bug, but does
bring many complications to the table about how resolve this. Current solution is to
turn expression macros (macros that specify a return value) into a `do` expression.
filename->kind = Ast_Kind_StrLit;
filename->token = str_token;
filename->addr = 0;
-
+
add_entities_for_node(NULL, (AstNode *) filename, NULL, NULL);
callsite->filename = filename;
call->va_kind = VA_Kind_Not_VA;
call->type = callee->type->Function.return_type;
- if (call->type == &type_auto_return) {
+ if (call->type == &type_auto_return && call->callee->kind != Ast_Kind_Macro) {
YIELD(call->token->pos, "Waiting for auto-return type to be solved.");
}
if (node->kind == Ast_Kind_Function) {
AstFunction* func = (AstFunction *) node;
-
+
if (func->entity_header && func->entity_header->state <= Entity_State_Check_Types) {
done = 0;
}
static SymresStatus symres_struct_defaults(AstType* t) {
if (t->kind != Ast_Kind_Struct_Type) return Symres_Error;
-
+
AstStructType* st = (AstStructType *) t;
if (st->scope) scope_enter(st->scope);
-
+
bh_arr_each(AstStructMember *, smem, st->members) {
if ((*smem)->initial_value != NULL) {
SYMRES(expression, &(*smem)->initial_value);
-
- // CLEANUP: I hate that this is here. The type inference for a struct member should happen once the actual type is known.
- // There seems to be a problem with setting it in the checker however, because whenever I disable this code, somehow
- // the compiler gets to the code generation without all the types figured out???
- // if ((*smem)->type_node == NULL && (*smem)->initial_value->type_node != NULL) {
- // (*smem)->type_node = (*smem)->initial_value->type_node;
- // }
}
}
-
+
if (st->scope) scope_leave();
return Symres_Success;
}
char* err_msg=NULL;
bh_arr(AstPolySolution) slns = find_polymorphic_slns(pp, PPLM_By_Arguments, args, &err_msg);
-
+
if (slns == NULL) {
if (flag_to_yield) {
flag_to_yield = 0;
}
if (callsite) onyx_report_error(callsite->pos, err_msg);
-
+
return NULL;
}
--- /dev/null
+#load "core/std"
+
+use package core
+
+Point :: struct { x, y: i32; }
+
+#add_match hash.to_u32, macro (p: Point) -> #auto do return p.x * 1000 + p.y;
+
+#operator == macro (p1: Point, p2: Point) -> #auto {
+ return p1.x == p2.x && p1.y == p2.y;
+}
+
+main :: (args) => {
+ S := set.make(Point);
+
+ S << Point.{ 1, 2 };
+ S << Point.{ 2, 3 };
+ S << Point.{ 1, 2 };
+
+ set.has(^S, Point.{ 1, 2 }) |> println();
+}
\ No newline at end of file