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

Assertion failure on identity comparison of tuples with different cardinalities #1946

Merged
merged 1 commit into from
Jun 7, 2017
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
14 changes: 8 additions & 6 deletions src/libponyc/codegen/genident.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,16 @@ static LLVMValueRef gen_is_value(compile_t* c, ast_t* left_type,

case LLVMStructTypeKind:
{
// Pairwise comparison.
if(LLVMGetTypeKind(r_type) == LLVMStructTypeKind)
return tuple_is(c, left_type, right_type, l_value, r_value);

// If left_type is a subtype of right_type, check if r_value is a boxed
// tuple.
if(is_subtype(left_type, right_type, NULL, c->opt))
{
// Pairwise comparison.
if(ast_childcount(left_type) == ast_childcount(right_type))
return tuple_is(c, left_type, right_type, l_value, r_value);
} else if(is_subtype(left_type, right_type, NULL, c->opt)) {
// If left_type is a subtype of right_type, check if r_value is a boxed
// tuple.
return raw_is_box(c, left_type, l_value, r_value);
}

// It can't have the same identity.
return LLVMConstInt(c->i1, 0, false);
Expand Down
17 changes: 17 additions & 0 deletions test/libponyc/codegen_identity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,23 @@ TEST_F(CodegenIdentityTest, BoxedTupleIsBoxedTuple)
}


TEST_F(CodegenIdentityTest, TupleCardinality)
{
const char* src =
"actor Main\n"
" new create(env: Env) =>\n"
" if (env, this, this) isnt (env, this) then\n"
" @pony_exitcode[None](I32(1))\n"
" end";

TEST_COMPILE(src);

int exit_code = 0;
ASSERT_TRUE(run_program(&exit_code));
ASSERT_EQ(exit_code, 1);
}


TEST_F(CodegenIdentityTest, DigestofObject)
{
const char* src =
Expand Down