Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify wording for some subtyping errors #3933

Merged
merged 8 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .release-notes/3933.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Clarify wording for some subtyping errors

The wording of a small number of errors relating
to the subtyping of capabilities were improved.
These were previously technically incorrect,
or otherwise unnecessarily obtuse.
4 changes: 2 additions & 2 deletions src/libponyc/expr/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ static bool check_arg_types(pass_opt_t* opt, ast_t* params, ast_t* positional,
if(!is_subtype(arg_type, wp_type, &info, opt))
{
errorframe_t frame = NULL;
ast_error_frame(&frame, arg, "argument not a subtype of parameter");
ast_error_frame(&frame, arg, "argument not assignable to parameter");
ast_error_frame(&frame, arg, "argument type is %s",
ast_print_type(arg_type));
ast_error_frame(&frame, param, "parameter type is %s",
ast_error_frame(&frame, param, "parameter type requires %s",
ast_print_type(wp_type));
errorframe_append(&frame, &info);

Expand Down
4 changes: 2 additions & 2 deletions src/libponyc/expr/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ static bool declared_ffi(pass_opt_t* opt, ast_t* call, ast_t* decl)
!is_subtype(a_type, p_type, &info, opt))
{
errorframe_t frame = NULL;
ast_error_frame(&frame, arg, "argument not a subtype of parameter");
ast_error_frame(&frame, arg, "argument not a assignable to parameter");
ast_error_frame(&frame, arg, "argument type is %s",
ast_print_type(a_type));
ast_error_frame(&frame, param, "parameter type is %s",
ast_error_frame(&frame, param, "parameter type requires %s",
ast_print_type(p_type));
errorframe_append(&frame, &info);
errorframe_report(&frame, opt->check.errors);
Expand Down
4 changes: 2 additions & 2 deletions src/libponyc/expr/lambda.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ static bool make_capture_field(pass_opt_t* opt, ast_t* capture,
if(!is_subtype(v_type, type, &info, opt))
{
errorframe_t frame = NULL;
ast_error_frame(&frame, value, "argument not a subtype of parameter");
ast_error_frame(&frame, value, "argument not assignable to parameter");
ast_error_frame(&frame, value, "argument type is %s",
ast_print_type(v_type));
ast_error_frame(&frame, id_node, "parameter type is %s",
ast_error_frame(&frame, id_node, "parameter type requires %s",
ast_print_type(p_type));
errorframe_append(&frame, &info);
errorframe_report(&frame, opt->check.errors);
Expand Down
3 changes: 2 additions & 1 deletion src/libponyc/type/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ static bool is_sub_cap_and_eph(ast_t* sub, ast_t* super, check_cap_t check_cap,
if(is_cap_sub_cap(ast_id(sub_cap), TK_EPHEMERAL, ast_id(super_cap),
ast_id(super_eph)))
ast_error_frame(errorf, sub_cap,
"this would be possible if the subcap were more ephemeral");
"this would be possible if the subcap were more ephemeral."
"Perhaps you meant to consume a variable here");
}

return false;
Expand Down
4 changes: 2 additions & 2 deletions test/libponyc/badpony.cc
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ TEST_F(BadPonyTest, AsFromUninferredReference)
" true";

TEST_ERRORS_2(src,
"argument not a subtype of parameter",
"argument not assignable to parameter",
"cannot infer type of b");
}

Expand Down Expand Up @@ -1047,7 +1047,7 @@ TEST_F(BadPonyTest, ThisViewpointWithIsoReceiver)
" let opaque : A tag = A.create()\n"
" let not_opaque : A box = (consume revealer).reveal(opaque)\n";

TEST_ERRORS_1(src, "argument not a subtype of parameter");
TEST_ERRORS_1(src, "argument not assignable to parameter");
}

TEST_F(BadPonyTest, DisallowPointerAndMaybePointerInEmbeddedType)
Expand Down
6 changes: 3 additions & 3 deletions test/libponyc/recover.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ TEST_F(RecoverTest, CanSee_LetLocalRefAsTag)
" let inner: Inner ref = Inner\n"
" recover Wrap(inner) end";

TEST_ERRORS_1(src, "argument not a subtype of parameter");
TEST_ERRORS_1(src, "argument not assignable to parameter");
}

TEST_F(RecoverTest, CanAccess_LetLocalVal)
Expand Down Expand Up @@ -128,7 +128,7 @@ TEST_F(RecoverTest, CanSee_VarLocalRefAsTag)
" var inner: Inner ref = Inner\n"
" recover Wrap(inner) end";

TEST_ERRORS_1(src, "argument not a subtype of parameter");
TEST_ERRORS_1(src, "argument not assignable to parameter");
}

TEST_F(RecoverTest, CanAccess_VarLocalVal)
Expand Down Expand Up @@ -172,7 +172,7 @@ TEST_F(RecoverTest, CanSee_ParamRefAsTag)
" fun apply(inner: Inner ref): Wrap iso =>\n"
" recover Wrap(inner) end";

TEST_ERRORS_1(src, "argument not a subtype of parameter");
TEST_ERRORS_1(src, "argument not assignable to parameter");
}

TEST_F(RecoverTest, CanAccess_ParamVal)
Expand Down