Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit 7b606d47 authored by Juan Wajnerman's avatar Juan Wajnerman
Browse files

Fix codegen of trampoline wrappers to no-return functions

parent ec4b363d
No related merge requests found
...@@ -43,6 +43,21 @@ describe "Code gen: fun" do ...@@ -43,6 +43,21 @@ describe "Code gen: fun" do
)).to_i.should eq(1) )).to_i.should eq(1)
end end
it "call fun pointer of instance method that raises" do
run(%(
require "prelude"
class Foo
def coco
raise "foo"
end
end
foo = Foo.new
f = ->foo.coco
f.call rescue 1
)).to_i.should eq(1)
end
it "codegens fun with another var" do it "codegens fun with another var" do
run(" run("
def foo(x) def foo(x)
......
...@@ -752,7 +752,9 @@ module Crystal ...@@ -752,7 +752,9 @@ module Crystal
LLVM.add_attribute func.get_param(0), LibLLVM::Attribute::Nest LLVM.add_attribute func.get_param(0), LibLLVM::Attribute::Nest
func.append_basic_block("entry") do |builder| func.append_basic_block("entry") do |builder|
call_ret = builder.call target_fun, func.params call_ret = builder.call target_fun, func.params
if target_def.type.void? if target_def.no_returns?
builder.unreachable
elsif target_def.type.void?
builder.ret builder.ret
else else
builder.ret call_ret builder.ret call_ret
......
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