luckyframework / lucky

A full-featured Crystal web framework that catches bugs for you, runs incredibly fast, and helps you write code that lasts.
https://luckyframework.org
MIT License
2.57k stars 156 forks source link

Forgetting a type restriction on an arg when using memoize has a bad error #1722

Closed jwoertink closed 1 year ago

jwoertink commented 1 year ago

If you have

memoize def foo(arg) : Hash(String, String)
  {"yo" => arg}
end

This will raise an error that looks like

There was a problem expanding macro 'memoize'

Called macro defined in eval:2:3

Which expanded to:

 > 2 |       Hash(String, String),
 > 3 |       
 > 4 |         ,
               ^
Error: unexpected token: ","

This doesn't really tell you what's going on. What it should say is "Each argument to memoize needs to have a type restriction" and then show the example.