From 52918cf10e7e0beab4e199ea1629e88d98f69640 Mon Sep 17 00:00:00 2001 From: Joe Eli McIlvain Date: Tue, 7 May 2024 11:17:11 -0700 Subject: [PATCH 1/2] Improve error message for generic subtyping. This make the error message a bit more helpful in cases like those seen in #4514. Resolves #4514 --- src/libponyc/type/subtype.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libponyc/type/subtype.c b/src/libponyc/type/subtype.c index 5e49d058ae..1c4f5fd648 100644 --- a/src/libponyc/type/subtype.c +++ b/src/libponyc/type/subtype.c @@ -216,7 +216,8 @@ static bool is_eq_typeargs(ast_t* a, ast_t* b, errorframe_t* errorf, if(!ret && errorf != NULL) { - ast_error_frame(errorf, a, "%s has different type arguments than %s", + ast_error_frame(errorf, a, + "%s has different type arguments than %s (the type arguments must be equivalent, not covariant nor contravariant)", ast_print_type(a), ast_print_type(b)); } From 4d559f341397a28d611abb24dfcd9bbac51f6d82 Mon Sep 17 00:00:00 2001 From: Joe Eli McIlvain Date: Tue, 7 May 2024 11:20:53 -0700 Subject: [PATCH 2/2] More improvements for generic subtpying error message. --- src/libponyc/type/subtype.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libponyc/type/subtype.c b/src/libponyc/type/subtype.c index 1c4f5fd648..14136a51f7 100644 --- a/src/libponyc/type/subtype.c +++ b/src/libponyc/type/subtype.c @@ -219,6 +219,9 @@ static bool is_eq_typeargs(ast_t* a, ast_t* b, errorframe_t* errorf, ast_error_frame(errorf, a, "%s has different type arguments than %s (the type arguments must be equivalent, not covariant nor contravariant)", ast_print_type(a), ast_print_type(b)); + ast_error_frame(errorf, a, + "this might be possible if either %s or %s were an interface rather than a concrete type", + ast_print_type(a), ast_print_type(b)); } // Make sure we had the same number of typeargs.