-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
regression in block return types #2347
Comments
Good catch, and thank you for taking the time to reduce the issue to those few lines. This bug alone might be a good reason to release 0.14.2 soon, because it's basically generating wrong code. |
Thank you for fixing it so quickly :) A new release soon would be good in this case, perhaps wait another 24 hours or so to see if more regressions are found? |
…c type than the specified return type. Fixes #2347
Wow. I just run this issue in def ws(path, &block : HTTP::WebSocket -> _)
Kemal::WebSocketHandler.new path, &block
end This works perfectly fine in 0.13.0 but throws the following error in 0.14.1.
|
Did you try using the master branch of crystal? The regression is not fixed in 0.14.1 but only in master. |
@benoist i'm waiting for the 0.14.2 release |
I just ran the kemal spec against master and your error message is still there. @asterite I have a similar issue in carbon with the callbacks |
I checked which commit causes the problems for kemal The problem in carbon is caused by |
@benoist @sdogruyol It's caused by this accepeted PR: #2313 Basically, now the websocket handler has also access to the HTTP::Context. We believed this was a backwards-compatible change because if you pass a block with just one block argument then it works. However, if you defined a method with the same block type and you forwarded it, you need to update it. So, you need to change your code to this: def ws(path, &block : HTTP::WebSocket, HTTP::Context -> _)
Kemal::WebSocketHandler.new path, &block
end That should solve the problem. |
@asterite is that syntax correct?
What would the, HTTP::Context -> _ do? |
I think multiple argument types need to be in parentheses. And it is less confusing this way. BTW I didn't know you can write _ instead of Void..
|
Ah right it's the arguments to the block. Yeah parens would help :-) |
Oh, just copied and pasted and added def ws(path, &block : HTTP::WebSocket, HTTP::Context -> ) # or Void
Kemal::WebSocketHandler.new path, &block
end The https://play.crystal-lang.org/#/r/uxx However, the compiler can implicitly convert a block that returns any type to one that returns void... because the later won't use the return value, so that's why using I should add this to the docs... 😕 |
In version 0.13.0 this used to work:
https://carc.in/#/r/uqv
In version 0.14.1 this throws a segfault
https://carc.in/#/r/uqx
The text was updated successfully, but these errors were encountered: