Skip to content

Commit

Permalink
Fix partial FFI declarations ignoring partial annotation
Browse files Browse the repository at this point in the history
Previously, the compiler would ignore any `?` annotations on FFI
declarations, which could result in the generated code lacking any
guards for errors, causing the final program to abort at runtime.
  • Loading branch information
ergl committed Feb 12, 2021
1 parent 4cd94dd commit 6438237
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .release-notes/3713.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Fix FFI declarations ignoring partial annotation

Previously, the compiler would ignore any `?` annotations on FFI declarations, which could result in the generated code lacking any guards for errors, causing the final program to abort at runtime. This change fixes the problem by ensuring that the compiler checks if FFI declarations specify a partial annotation.
2 changes: 1 addition & 1 deletion src/libponyc/codegen/gencall.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ LLVMValueRef gen_ffi(compile_t* c, ast_t* ast)
if(decl != NULL)
{
// Define using the declared types.
AST_GET_CHILDREN(decl, decl_id, decl_ret, decl_params, decl_err);
AST_GET_CHILDREN(decl, decl_id, decl_ret, decl_params, decl_named_params, decl_err);
err = (ast_id(decl_err) == TK_QUESTION);
func = declare_ffi(c, f_name, t, decl_params, false);
} else if(!strncmp(f_name, "llvm.", 5) || !strncmp(f_name, "internal.", 9)) {
Expand Down

0 comments on commit 6438237

Please sign in to comment.