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!: Expression.Return.get_value can be null #149

Merged
merged 2 commits into from
Apr 8, 2022
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
7 changes: 6 additions & 1 deletion src/binaryen_stubs_expressions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,12 @@ CAMLprim value
caml_binaryen_return_get_value(value _exp) {
CAMLparam1(_exp);
BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
CAMLreturn(alloc_BinaryenExpressionRef(BinaryenReturnGetValue(exp)));
BinaryenExpressionRef val = BinaryenReturnGetValue(exp);
if (val == NULL) {
CAMLreturn(Val_none);
} else {
CAMLreturn(caml_alloc_some(alloc_BinaryenExpressionRef(val)));
}
}

CAMLprim value
Expand Down
2 changes: 1 addition & 1 deletion src/binaryen_stubs_expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ function caml_binaryen_drop_set_value(exp, value) {
//Provides: caml_binaryen_return_get_value
//Requires: binaryen
function caml_binaryen_return_get_value(exp) {
return binaryen.Return.getValue(exp);
return to_option(binaryen.Return.getValue(exp));
}

//Provides: caml_binaryen_return_set_value
Expand Down
2 changes: 1 addition & 1 deletion src/expression.ml
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ end

module Return = struct
external make : Module.t -> t -> t = "caml_binaryen_return"
external get_value : t -> t = "caml_binaryen_return_get_value"
external get_value : t -> t option = "caml_binaryen_return_get_value"
external set_value : t -> t -> unit = "caml_binaryen_return_set_value"
end

Expand Down
2 changes: 1 addition & 1 deletion src/expression.mli
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ end

module Return : sig
val make : Module.t -> t -> t
val get_value : t -> t
val get_value : t -> t option
val set_value : t -> t -> unit
end

Expand Down