From e6ac69bdca16b5c5f03476e682fbffa9af6eb0c5 Mon Sep 17 00:00:00 2001 From: Ary Borenszweig Date: Thu, 26 Jul 2018 20:50:30 -0300 Subject: [PATCH] Compiler: missing `request_value` in `not` call --- spec/compiler/codegen/not_spec.cr | 12 ++++++++++++ src/compiler/crystal/codegen/codegen.cr | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/spec/compiler/codegen/not_spec.cr b/spec/compiler/codegen/not_spec.cr index 3dda494fcf1f..99a0520ed639 100644 --- a/spec/compiler/codegen/not_spec.cr +++ b/spec/compiler/codegen/not_spec.cr @@ -55,4 +55,16 @@ describe "Code gen: not" do !a.is_a?(String) && !a )).to_b.should be_false end + + it "codegens not with inlinable value (#6451)" do + codegen(%( + class Test + def test + false + end + end + + !Test.new.test + nil)) + end end diff --git a/src/compiler/crystal/codegen/codegen.cr b/src/compiler/crystal/codegen/codegen.cr index 236b525b48c4..c2f98a3d51ba 100644 --- a/src/compiler/crystal/codegen/codegen.cr +++ b/src/compiler/crystal/codegen/codegen.cr @@ -815,7 +815,9 @@ module Crystal end def visit(node : Not) - accept node.exp + request_value do + accept node.exp + end @last = codegen_cond node.exp.type.remove_indirection @last = not @last false