Don't generate code for NODE_NEGATE if the result isn't used

Reported by https://hackerone.com/haquaman
parent 5930a6eb
......@@ -2223,6 +2223,10 @@ codegen(codegen_scope *s, node *tree, int val)
{
nt = (intptr_t)tree->car;
tree = tree->cdr;
if (!val) {
codegen(s, tree, NOVAL);
break;
}
switch (nt) {
case NODE_FLOAT:
{
......
......@@ -63,3 +63,13 @@ assert('splat in case splat') do
assert_equal [1], a
end
assert('negate literal register alignment') do
a = *case
when 0
-0.0
2
end
assert_equal [2], a
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment