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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user