Closed jwoertink closed 2 years ago
@jwoertink The action is unrelated to the error. Notice the Handled by Hierarchy::Products
isn't the same action as the one pasted in. Looks like it's just a compilation error in the listed action
oh, good catch on that.
@bruceperens do you have the error from this action that uses the optional path param?
It's the same code as the one pasted. Only the query is changed. All three (each has a different query) failed at runtime. Also, this is not a compilation error, it happens at runtime. I haven't figured out what throws a plain Exception with "can't execute" as its message. But the backtick might be a clue.
Ok, thanks. I'll try to dig in more when I get a moment.
It's a runtime complaint from the compiler about an untyped expression in a macro, with the unfortunately still-too-frequent singularly unhelpful message which doesn't say untyped expression in a macro: ./src/compiler/crystal/semantic/cleanup_transformer.cr: str << "can't execute
" << node << "at " << node.location
Also, the compiler is just printing the intermediately generated AST node rather than the source filename or line number. So, it doesn't really help you find where your macro expression generates something untyped.
Sorry, the previous location I posted was wrong.
It's the macro code at https://github.com/luckyframework/lucky/blob/b6f68bdc78b0b6831e801cac3ba0c97f83159e81/src/lucky/routable.cr#L96 What it's doing is a bit over my head.
That bit of code just ensures that each before
/ after
pipe either returns continue
or some response like redirect
, etc... Do you have any before/after pipes that are running around these actions?
At least two things that I think are @akadusei code from Shield:
check_authorization
require_logged_in
Pardon if this sounds too much like a gripe. But does this really need to be in a macro? My sense is that Lucky is a bit macro-happy, and the error messages suffer because of that and programmer acceptance is hurt by the incomprehensibility of Crystal error messages for macro code. Not that you have time for a big rewrite.
does this really need to be in a macro?
Yup. Keep in mind that Lucky's first priority goal is compile-time catching of bugs for development. The only way we can achieve this is by the heavy use of macros. Granted, the error messages aren't as nice as we wish they were, but several issues have been opened in Crystal to help address that.
I know it can be pretty frustrating sometimes, but these sorts of issues help us to improve so after we hit 1.0, newcomers don't go through these nearly as often. As always, I appreciate the feedback!
I haven't been able to recreate the original issue. I've added a spec to Lucky to ensure that at least the next release ensures it works. I'm gonna close this out, but if anyone finds an easy way to reproduce this, we can open back up.
From Discord:
This code
throws this error:
Removing the optional flag
?
from the param fixes it... Could it be this line specifically?letter = params.get?(:letter)
??