Add intrinsics.procedure_of

```odin
foo :: proc(x: $T) { fmt.println(x) }
bar :: intrinsics.procedure_of(foo(int(123))) // parameters are never ran at compile time, similar to `size_of`
bar(333) // prints 333
```
This commit is contained in:
gingerBill
2024-06-10 15:02:34 +01:00
parent 1945218f6d
commit fa3cae2bb0
9 changed files with 87 additions and 6 deletions

View File

@@ -2224,8 +2224,16 @@ gb_internal void check_expr_stmt(CheckerContext *ctx, Ast *node) {
}
if (do_require) {
gbString expr_str = expr_to_string(ce->proc);
defer (gb_string_free(expr_str));
if (builtin_id) {
String real_name = builtin_procs[builtin_id].name;
if (real_name != make_string(cast(u8 const *)expr_str, gb_string_length(expr_str))) {
error(node, "'%s' ('%.*s.%.*s') requires that its results must be handled", expr_str,
LIT(builtin_proc_pkg_name[builtin_procs[builtin_id].pkg]), LIT(real_name));
return;
}
}
error(node, "'%s' requires that its results must be handled", expr_str);
gb_string_free(expr_str);
}
return;
} else if (expr && expr->kind == Ast_SelectorCallExpr) {