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

Do not allow capability subtyping when checking constraint subtyping. #1816

Merged
merged 2 commits into from
Apr 7, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/libponyc/type/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ static bool is_reified_fun_sub_fun(ast_t* sub, ast_t* super,
ast_t* sub_constraint = ast_childidx(sub_typeparam, 1);
ast_t* super_constraint = ast_childidx(super_typeparam, 1);

if(!is_x_sub_x(super_constraint, sub_constraint, CHECK_CAP_SUB, errorf,
if(!is_x_sub_x(super_constraint, sub_constraint, CHECK_CAP_EQ, errorf,
opt))
{
if(errorf != NULL)
Expand Down
13 changes: 13 additions & 0 deletions test/libponyc/badpony.cc
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,16 @@ TEST_F(BadPonyTest, AnnotatedIfClause)

TEST_COMPILE(src);
}

TEST_F(BadPonyTest, CapSubtypeInConstrainSubtyping)
{
// From PR #1816
const char* src =
"trait T\n"
" fun alias[X: Any iso](x: X!) : X^\n"
"class C is T\n"
" fun alias[X: Any tag](x: X!) : X^ => x\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a small style point, but could you remove the "extra" space before the colon that precedes the return type?

This would make it more closely match the prevailing style in these tests and in the standard libraries.


TEST_ERRORS_1(src,
"type parameter constraint Any tag is not a supertype of Any iso");
}