| ... | ... | @@ -3696,6 +3696,29 @@ fn fnDecl( |
| 3696 | 3696 | if (param.anytype_ellipsis3) |tok| { |
| 3697 | 3697 | return astgen.failTok(tok, "missing parameter name", .{}); |
| 3698 | 3698 | } else { |
| 3699 | ambiguous: { |
| 3700 | if (tree.nodes.items(.tag)[param.type_expr] != .identifier) break :ambiguous; |
| 3701 | const main_token = tree.nodes.items(.main_token)[param.type_expr]; |
| 3702 | const identifier_str = tree.tokenSlice(main_token); |
| 3703 | if (isPrimitive(identifier_str)) break :ambiguous; |
| 3704 | return astgen.failNodeNotes( |
| 3705 | param.type_expr, |
| 3706 | "missing parameter name or type", |
| 3707 | .{}, |
| 3708 | &[_]u32{ |
| 3709 | try astgen.errNoteNode( |
| 3710 | param.type_expr, |
| 3711 | "if this is a name, annotate its type '{s}: T'", |
| 3712 | .{identifier_str}, |
| 3713 | ), |
| 3714 | try astgen.errNoteNode( |
| 3715 | param.type_expr, |
| 3716 | "if this is a type, give it a name '<name>: {s}'", |
| 3717 | .{identifier_str}, |
| 3718 | ), |
| 3719 | }, |
| 3720 | ); |
| 3721 | } |
| 3699 | 3722 | return astgen.failNode(param.type_expr, "missing parameter name", .{}); |
| 3700 | 3723 | } |
| 3701 | 3724 | } else 0; |