Skip to content
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

Memoize doesn't work with predicate methods #1396

Closed
jwoertink opened this issue Jan 22, 2021 · 0 comments · Fixed by #1727
Closed

Memoize doesn't work with predicate methods #1396

jwoertink opened this issue Jan 22, 2021 · 0 comments · Fixed by #1727
Labels

Comments

@jwoertink
Copy link
Member

jwoertink commented Jan 22, 2021

Related: luckyframework/lucky_cli#508

Memoizing predicate methods fails

memoize def find_user? : String
  "test"
end
web          | There was a problem expanding macro 'memoize'
web          |
web          | Code in src/actions/browser_action.cr:31:3
web          |
web          |  31 | memoize def find_user? : String
web          |       ^
web          | Called macro defined in lib/lucky/src/lucky/memoizable.cr:22:3
web          |
web          |  22 | macro memoize(method_def)
web          |
web          | Which expanded to:
web          |
web          |  > 2 |
web          |  > 3 |
web          |  > 4 |     @__memoized_find_user? : Tuple(
web          |                                   ^
web          | Error: unexpected token: :
@jwoertink jwoertink added the bug label Jan 22, 2021
akadusei added a commit to GrottoPress/shield that referenced this issue Jul 30, 2021
Memoize has [issues][issues], and I've never really had a use case
for memoizing a method that has arguments.

See luckyframework/lucky#1388

[issues]: luckyframework/lucky#1396
@jwoertink jwoertink added the hacktoberfest Valid Issue for Hacktoberfest label Oct 1, 2021
@jwoertink jwoertink removed the hacktoberfest Valid Issue for Hacktoberfest label Nov 1, 2021
@jwoertink jwoertink changed the title Issues with Memoize edge cases Memoize doesn't work with predicate methods Aug 28, 2022
jwoertink added a commit that referenced this issue Sep 6, 2022
* Fixing memoize edge cases with predicate and bang methods. Fixes #1396

* cleaning up code and applying suggestions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant