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

Fix serialisation of Array and String #2246

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions src/libponyc/codegen/genprim.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ void genprim_array_serialise_trace(compile_t* c, reach_type_t* t)
LLVMBasicBlockRef post_block = codegen_block(c, "post");

LLVMValueRef cond = LLVMBuildICmp(c->builder, LLVMIntNE, size,
LLVMConstInt(c->intptr, 0, false), "");
LLVMConstInt(c->intptr, PONY_TRACE_OPAQUE, false), "");
LLVMBuildCondBr(c->builder, cond, trace_block, post_block);

LLVMPositionBuilderAtEnd(c->builder, trace_block);
Expand Down Expand Up @@ -1048,7 +1048,7 @@ void genprim_string_serialise_trace(compile_t* c, reach_type_t* t)
LLVMBasicBlockRef post_block = codegen_block(c, "post");

LLVMValueRef cond = LLVMBuildICmp(c->builder, LLVMIntNE, size,
LLVMConstInt(c->intptr, 0, false), "");
LLVMConstInt(c->intptr, PONY_TRACE_OPAQUE, false), "");
LLVMBuildCondBr(c->builder, cond, trace_block, post_block);

LLVMPositionBuilderAtEnd(c->builder, trace_block);
Expand Down
28 changes: 28 additions & 0 deletions test/libponyc/codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,34 @@ TEST_F(CodegenTest, ViewpointAdaptedFieldReach)
}


TEST_F(CodegenTest, StringSerialization)
{
// From issue 2245
const char* src =
"use \"serialise\"\n"

"class V\n"
" let _v: String = \"\"\n"

"actor Main\n"
" new create(env: Env) =>\n"
" try\n"
" let auth = env.root as AmbientAuth\n"
" let v: V = V\n"
" Serialised(SerialiseAuth(auth), v)?\n"
" @pony_exitcode[None](I32(1))\n"
" end";

set_builtin(NULL);

TEST_COMPILE(src);

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


TEST_F(CodegenTest, CustomSerialization)
{
const char* src =
Expand Down