Conversation
|
The OSX CI is failing because this line needs to be >= 3.8, not 3.8 or 3.9. OSX CI uses LLVM 5. Since we don't support LLVM 3.5 any more, I say just remove the condition entirely. We should support that method on all LLVM versions we support. |
|
@txe Thank you for this! I guess there's no way to catch exceptions in Windows other than rewrite it to a series of About it failing without You can use the def transform(node : Rescue)
# create an `if` node and set its location to the same as the rescue node
an_if = If.new(...).at(node)
endYou should do that will all nodes that you create. The codegen debug logic needs all nodes to have a location, otherwise sometimes you will get an LLVM error. |
|
Thanks! I knew it was about creating a new node, just didn't know how to set a location. |
|
I think I finished this PR. For some reason, it couldn't pass The Travis CI. |
|
@txe Master is failing because a recent PR was merged and that broke it (because it missed a rebase). Not a problem with this PR. |
|
@txe master's fixed now, can you rebase this PR? |
|
|
||
| # # 2) | ||
| # # If there's an else, we take the value from it. | ||
| # # Otherwise, the value is taken from the body. |
| # # lp_ret_type = llvm_typer.landing_pad_type | ||
| # # lp = builder.landing_pad lp_ret_type, main_fun(self.personality_name), [] of LLVM::Value | ||
| # # unwind_ex_obj = extract_value lp, 0 | ||
| # # ex_type_id = extract_value lp, 1 |
| if node_rescues | ||
| # if node_ensure | ||
| # rescue_ensure_block = new_block "rescue_ensure" | ||
| # end |
| @rescue_block = rescue_ensure_block || @rescue_block | ||
|
|
||
| # node_rescues.each do |a_rescue| | ||
| # end |
| Call.global("raise", Var.new(var_name)).at(node), | ||
| ] of ASTNode), nil, var_name)]) | ||
| tap_block = Block.new(@args = [] of Var, ensure_body.clone) | ||
| return Expressions.from [Call.new(new_handler, "tap", [] of ASTNode, tap_block)] of ASTNode |
There was a problem hiding this comment.
We shouldn't use tap for this, creating new dependencies in the stdlib. I'd rather you just implemented this as
___tempvar = begin ... end
ensure_body
___tempvarThere was a problem hiding this comment.
Actually, the code was like that, I had to use tap to fix another issue. Please, read this comment. Considering the purpose of SimpleRescues, can we leave it as it is?
There was a problem hiding this comment.
but the code I put above is equivalent to the tap call, since it captures __tempvar and ensures it's the last item of the Expressions so that it has the correct type.
There was a problem hiding this comment.
Yeah, you are right, I just misunderstood the code.
src/raise.cr
Outdated
|
|
||
| fun __crystal_personality(version : Int32, actions : LibUnwind::Action, exception_class : UInt64, exception_object : LibUnwind::Exception*, context : Void*) : LibUnwind::ReasonCode | ||
| LibUnwind::ReasonCode::NO_REASON | ||
| #exception.inspect_with_backtrace(STDERR) |
|
This snippet should print "before" then "after", but on windows it only prints "before" then exits with code 29. class Foo < Exception
end
p "before"
begin
raise "foo"
rescue ex
ex.class == Foo
end
p "after" |
|
Seems like unwinding a "long way" has a lot of issues too. For example raising in a deeply nested call rarely prints the exception in It's a fantastic step forwards but it seems a little buggy :( |
|
@txe Are you still working on this? =) Would be awesome to proceed with Windows support. 👍 |
|
@straight-shoota Sorry, I don't think I'm going to work on it. |
|
@txe sad to hear that, hope you will decide to tackle it or other issues again in the future |
|
Superseeded by #6419 |
I've ported code related to win exceptions from my previous branch and this code works, more or less.
There is one issue so far, you will need to use --no-debug when cross compile code. I'll fix it soon.
cc @RX14