Fix short-circuiting operators (SQUASH)

This commit is contained in:
Nikita Lisitsa 2026-03-30 20:29:25 +03:00
parent ac6eacd80b
commit b8658816b4

View file

@ -136,7 +136,7 @@ namespace pslang::ir
if (node.type == ast::binary_operation_type::logical_and) if (node.type == ast::binary_operation_type::logical_and)
{ {
mcontext.nodes->emplace_back(copy{arg1}); mcontext.nodes->emplace_back(copy{arg1}, ast::get_type(*node.arg1));
auto result = last(); auto result = last();
mcontext.nodes->emplace_back(jump_if_zero{result}); mcontext.nodes->emplace_back(jump_if_zero{result});
auto jump = last(); auto jump = last();
@ -150,7 +150,7 @@ namespace pslang::ir
if (node.type == ast::binary_operation_type::logical_or) if (node.type == ast::binary_operation_type::logical_or)
{ {
mcontext.nodes->emplace_back(copy{arg1}); mcontext.nodes->emplace_back(copy{arg1}, ast::get_type(*node.arg1));
auto result = last(); auto result = last();
mcontext.nodes->emplace_back(unary_operation{ast::unary_operation_type::logical_not, result}, node.inferred_type); mcontext.nodes->emplace_back(unary_operation{ast::unary_operation_type::logical_not, result}, node.inferred_type);
mcontext.nodes->emplace_back(jump_if_zero{last()}); mcontext.nodes->emplace_back(jump_if_zero{last()});