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

Cant initialize wrapper via constructor #57

Open
revati opened this issue Jun 7, 2019 · 5 comments
Open

Cant initialize wrapper via constructor #57

revati opened this issue Jun 7, 2019 · 5 comments
Labels

Comments

@revati
Copy link

revati commented Jun 7, 2019

Following the example in docs, I created a module

defmodule Id do
  import Algae

  defdata any()
end

when I try to call Id.new("random value") i get following error:

** (FunctionClauseError) no function clause matching in anonymous fn/2 in Kernel.struct/2

    The following arguments were given to anonymous fn/2 in Kernel.struct/2:

        # 1
        :id

        # 2
        %Id{id: nil}

    (elixir) lib/kernel.ex:1975: anonymous fn/2 in Kernel.struct/2
    (elixir) lib/enum.ex:1925: Enum."-reduce/3-lists^foldl/2-0-"/3

Environment:

$ elixir -v
Erlang/OTP 21 [erts-10.3.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Elixir 1.7.4 (compiled with Erlang/OTP 19)

$ cat mix.lock
%{
  "algae": {:hex, :algae, "1.2.3", "6ec177482faa12573a7edc65380fe5c9cdfa52ab32e01d0753aa52425b220827", [:mix], [{:quark, "~> 2.3", [hex: :quark, repo: "hexpm", optional: false]}, {:type_class, "~> 1.2", [hex: :type_class, repo: "hexpm", optional: false]}, {:witchcraft, "~> 1.0", [hex: :witchcraft, repo: "hexpm", optional: false]}], "hexpm"},
  "exceptional": {:hex, :exceptional, "2.1.1", "f18f8c1be63aab7fe8f3000cf2a8678936544fc39af1e2bc4a5c3c9e38cd8899", [:mix], [], "hexpm"},
  "operator": {:hex, :operator, "0.2.0", "b613bdb520a20dbc016d921d444fd2ef2212136be9385d6dca448a2a38d0577f", [:mix], [], "hexpm"},
  "quark": {:hex, :quark, "2.3.0", "3742ddc14441b4930c7067741879cb5b3e4881f391ea0aed7b138f20d16b30bb", [:mix], [], "hexpm"},
  "type_class": {:hex, :type_class, "1.2.5", "b972bb22202e801d83e8670228d9a1476cd2c9fc7da00b7039b19d6d06b17905", [:mix], [{:exceptional, "~> 2.1", [hex: :exceptional, repo: "hexpm", optional: false]}], "hexpm"},
  "witchcraft": {:hex, :witchcraft, "1.0.1", "5db4f9f92be480958a51bee01d3fd283a707576e5e0a0810d4442eac1f47e395", [:mix], [{:exceptional, "~> 2.1", [hex: :exceptional, repo: "hexpm", optional: false]}, {:operator, "~> 0.2", [hex: :operator, repo: "hexpm", optional: false]}, {:quark, "~> 2.2", [hex: :quark, repo: "hexpm", optional: false]}, {:type_class, "~> 1.2", [hex: :type_class, repo: "hexpm", optional: false]}], "hexpm"},
}
@icidasset

This comment has been minimized.

@OvermindDL1
Copy link

Isn't his example precisely what the readme states is how it should be used?
https://github.com/witchcrafters/algae#constructor

@icidasset
Copy link
Member

Ah, I misunderstood, thanks @OvermindDL1! I assumed the shorthand syntax (the syntax without a do block, which this person is using) didn't have any fields, but that's not the case (it has one field).

So yeah, that looks like a bug.
Will look into this more soon.
Thanks for the report @revati !

@icidasset icidasset added the bug label Jul 8, 2019
@cognivore
Copy link

Got same behaviour just now, also with newtype form of defdata.

@florius0
Copy link

Similar results on Elixir 1.12.3

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

No branches or pull requests

5 participants