lang: opt-in UFCS — ufcs-marked fns + alias dot-dispatch, generic binding via receiver; one binding builder for plan-side generic returns

This commit is contained in:
agra
2026-06-11 17:04:51 +03:00
parent 84e0fb0752
commit a47ea1416e
27 changed files with 316 additions and 137 deletions

View File

@@ -266,11 +266,18 @@ pub const Parser = struct {
return self.parseUnionDecl(name, start_pos, name_is_raw);
}
// UFCS alias: name :: ufcs target;
// UFCS forms:
// name :: ufcs (params) -> ret { body } — fn declared dot-callable
// name :: ufcs target; — dot-callable alias
if (self.current.tag == .kw_ufcs) {
self.advance();
if (self.current.tag == .l_paren) {
const node = try self.parseFnDecl(name, name_span, name_is_raw, start_pos);
node.data.fn_decl.is_ufcs = true;
return node;
}
if (self.current.tag != .identifier) {
return self.fail("expected function name after 'ufcs'");
return self.fail("expected '(' (a ufcs function declaration) or a function name (a ufcs alias) after 'ufcs'");
}
const target = self.tokenSlice(self.current);
self.advance();