From 670ddbe1cf037c55030a14f5a55890348743c2de Mon Sep 17 00:00:00 2001 From: Akuli Date: Sun, 5 Jan 2025 13:16:15 +0200 Subject: [PATCH] Print it properly --- self_hosted/ast.jou | 8 +++++++- src/print.c | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/self_hosted/ast.jou b/self_hosted/ast.jou index b5e82010..bcf3b890 100644 --- a/self_hosted/ast.jou +++ b/self_hosted/ast.jou @@ -677,7 +677,13 @@ class AstSignature: for i = 0; i < self->nargs; i++: if i != 0: printf(", ") - if strcmp(self->args[i].name, "self") == 0: + + if ( + strcmp(self->args[i].name, "self") == 0 + and self->args[i].type.kind == AstTypeKind::Named + and self->args[i].type.name[0] == '\0' + ): + # self with implicitly given type printf("self") else: self->args[i].print_with_tree_printer(NULL) diff --git a/src/print.c b/src/print.c index 9d081d22..a20a062c 100644 --- a/src/print.c +++ b/src/print.c @@ -172,9 +172,10 @@ static void print_ast_function_signature(const AstSignature *sig) printf("%s(", sig->name); for (const AstNameTypeValue *ntv = sig->args.ptr; ntv < End(sig->args); ntv++) { if (ntv > sig->args.ptr) printf(", "); - if (!strcmp(ntv->name, "self")) + if (!strcmp(ntv->name, "self") && ntv->type.kind == AST_TYPE_NAMED && ntv->type.data.name[0] == '\0') { + // self with implicitly given type printf("self"); - else{ + } else { printf("%s: ", ntv->name); print_ast_type(&ntv->type); }