Skip to content

Commit

Permalink
[#58] fix(script): fix function parameters
Browse files Browse the repository at this point in the history
This commit fixes a crash with higher-order functions. Previously, passing a function as a parameter might cause the callee to copy its value into a local variable which did not have enough space for the function value.

With this fix, one integer of space is allocated for non-const function symbols which should fix that issue.
  • Loading branch information
lmichaelis committed Feb 14, 2023
1 parent c6cb69d commit f0d6751
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source/script.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ namespace phoenix {
sym._m_value = std::shared_ptr<instance> {nullptr};
[[fallthrough]];
case datatype::function:
if (!sym.is_const()) {
sym._m_value = std::unique_ptr<std::int32_t[]>(new int32_t[1]);
}
[[fallthrough]];
case datatype::prototype:
sym._m_address = in.get_int();
break;
Expand Down

0 comments on commit f0d6751

Please sign in to comment.