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

protocol Enumerable not implemented for nil #191

Closed
vraravam opened this issue Jan 14, 2017 · 3 comments
Closed

protocol Enumerable not implemented for nil #191

vraravam opened this issue Jan 14, 2017 · 3 comments

Comments

@vraravam
Copy link

vraravam commented Jan 14, 2017

Using the latest master of this repo (d2d901e), my specs fail with the following error:

	** (Protocol.UndefinedError) protocol Enumerable not implemented for nil
    (elixir) lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir) lib/enum.ex:116: Enumerable.reduce/3
    (elixir) lib/enum.ex:1636: Enum.reduce/3
    (elixir) lib/enum.ex:1188: Enum.map/2
    (ex_machina) lib/ex_machina/ecto_strategy.ex:74: anonymous fn/2 in ExMachina.EctoStrategy.cast_all_assocs/1
    (elixir) lib/enum.ex:1623: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ex_machina) lib/ex_machina/ecto_strategy.ex:17: ExMachina.EctoStrategy.handle_insert/2

Please fix asap.

@jsteiner
Copy link
Contributor

jsteiner commented Jan 14, 2017

Can you provide more info on the failing spec, such as the spec and any relevant factories?

@vraravam
Copy link
Author

@jsteiner - The whole codebase is open source. The specific factory is here.

@jsteiner
Copy link
Contributor

jsteiner commented Jan 26, 2017

I've added a failing test to reproduce this here: https://github.com/thoughtbot/ex_machina/compare/js-nil

jsteiner added a commit that referenced this issue Jan 27, 2017
Previously the catchall was falling through to the list case and trying
to enumerate `nil`. This commit adds a guard to the list condition to
ensure that doesn't happen again, then adds a new condition to handle
`nil`.

I _think_ this should be handling all cases now, so it also removes the
catchall. This way, if it fails in a way we didn't expect, it should
give an obvious failure that there was no matching case.

Fixes #191
jsteiner added a commit that referenced this issue Jan 27, 2017
Previously the catchall was falling through to the list case and trying
to enumerate `nil`. This commit adds a guard to the list condition to
ensure that doesn't happen again, then adds a new condition to handle
`nil`.

I _think_ this should be handling all cases now, so it also removes the
catchall. This way, if it fails in a way we didn't expect, it should
give an obvious failure that there was no matching case.

Fixes #191
jsteiner added a commit that referenced this issue Jan 27, 2017
Previously the catchall was falling through to the list case and trying
to enumerate `nil`. This commit adds a guard to the list condition to
ensure that doesn't happen again, then adds a new condition to handle
`nil`.

I _think_ this should be handling all cases now, so it also removes the
catchall. This way, if it fails in a way we didn't expect, it should
give an obvious failure that there was no matching case.

Fixes #191
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants