// HACK HACK HACK This is probably very wrong. I don't know what guarentees that
// the paramters and arguments are going to be in the same order exactly.
- // Type *any_type = type_build_from_ast(context.ast_alloc, builtin_any_type);
+ Type *any_type = type_build_from_ast(context.ast_alloc, builtin_any_type);
fori (i, 0, bh_arr_length(call->args.values)) {
AstNode *value = (AstNode *) ((AstArgument *) call->args.values[i])->value;
- // assert(template->params[i].local->type);
+ assert(template->params[i].local->type);
+
+ Type *param_type = template->params[i].local->type;
+ if (param_type == any_type
+ || (param_type->kind == Type_Kind_VarArgs && param_type->VarArgs.elem == any_type)) {
+ onyx_report_error(macro->token->pos, "Currently, macros do not support arguments of type 'any' or '..any'.");
+ }
symbol_introduce(argument_scope, template->params[i].local->token, value);
}
reader := io.reader_make(^file);
defer os.close(^file);
- nums := array.make(i32);
+ nums: [..] i32;
while !io.reader_empty(^reader) {
nums << io.read_u32(^reader);
io.skip_whitespace(^reader);
}
{ // Part 2
- windows := array.make(i32);
+ windows: [..] i32;
for i: range.{ 0, nums.count - 2 } {
sum := 0;
for k: i .. i+3 do sum += nums[k];
for os.with_file("./tests/aoc-2021/input/day03.txt") {
reader := io.reader_make(it);
- nums := array.make(i32);
+ nums: [..] i32;
while !io.reader_empty(^reader) {
nums << read_binary(^reader);
}
}
cast_able_to_int :: #match {
- macro (_: $T) -> bool where CanCastTo(T, i32) { return true; },
- macro (_: any) -> bool { return false; },
+ macro (_: $T) -> bool where CanCastTo(T, i32) { return true; },
+ macro (_: $T) -> bool { return false; },
}
do_math :: macro (x, y: $T) -> T where SemiRing(T) {