SYMRES(expression, (AstTyped **) &add_overload->overloaded_function);
if (add_overload->overloaded_function == NULL) return Symres_Error; // NOTE: Error message will already be generated
- if (add_overload->overloaded_function->kind != Ast_Kind_Overloaded_Function) {
+ AstOverloadedFunction *ofunc = (AstOverloadedFunction *) strip_aliases((AstNode *) add_overload->overloaded_function);
+ if (ofunc->kind == Ast_Kind_Symbol) {
+ if (context.cycle_detected) {
+ onyx_report_error(add_overload->token->pos, Error_Waiting_On, "Waiting for matched procedure to be known.");
+ return Symres_Error;
+ }
+
+ return Symres_Yield_Macro;
+ }
+
+ if (ofunc->kind != Ast_Kind_Overloaded_Function) {
onyx_report_error(add_overload->token->pos, Error_Critical, "#match directive expects a matched procedure.");
return Symres_Error;
}
- AstOverloadedFunction* ofunc = (AstOverloadedFunction *) add_overload->overloaded_function;
if (ofunc->locked) {
onyx_report_error(add_overload->token->pos, Error_Critical, "Cannot add match option here as the original #match was declared as #locked.");
onyx_report_error(ofunc->token->pos, Error_Critical, "Here is the original #match.");
package core.hash
-to_u32 :: #match -> u32 {
+//
+// DEPRECATED: to_u32 is the old name that kind of
+// makes sense, but is a little unintuitive. Use
+// core.hash.hash instead.
+to_u32 :: hash
+
+//
+// This overloaded procedure defines how to hash something.
+// It is used throughout the standard library to hash values.
+// There are many overloads to it in the standard library, and
+// more can be added using #overload. Or, a hash method can be
+// defined for a structure or distinct type.
+//
+// Person :: struct {
+// hash :: (p: Person) {
+// return // ...
+// }
+// }
+
+hash :: #match -> u32 {
// Does this need to have a higher precedence value?
// Because if I wanted to have a custom type as the key
// of a map that only looks at some of the members of the
}
Hashable :: interface (t: $T) {
- { to_u32(t) } -> u32;
+ { hash(t) } -> u32;
}
#local