-
Notifications
You must be signed in to change notification settings - Fork 50
Closed
Description
Environment
-
Elixir & Erlang versions (elixir --version):
Erlang/OTP 21 [erts-10.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
Elixir (1.6.6) -
Operating system:
macOS 10.13.5 -
Client (editor or IDE):
vsCode 1.25.1
Basically an Ecto schema with a derive macro for Jason will show an incorrect error. Unfortunately, I missed grabbing the dev logs.
Code:
defmodule MyApp.MailData do
@derive {Jason.Encoder,
only: [:to, :subject, :sendgrid_template, :extra_data, :send_attempts, :priority]}
schema "mail_data" do
field(:to, :string)
field(:subject, :string)
field(:sendgrid_template, :string, default: "")
field(:extra_data, :map, default: %{})
field(:send_attempts, :integer, default: 0)
field(:priority, :integer, default: 0)
end
end
Error:
[Elixir]
** (BadArityError) #Function<1.119002335/3 in Jason.Codegen.encode_pair/2> with arity 3 called with 4 arguments ("to", "to", 0, [])
lib/encode.ex:239: Jason.Encode.key/2
lib/codegen.ex:126: Jason.Codegen.encode_pair/2
(elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
lib/codegen.ex:48: Jason.Codegen.build_kv_iodata/2
expanding macro: Jason.Encoder.Any.__deriving__/3
lib/emails/mail_data.ex:21: MyApp.MailData (module)
(elixir) lib/module.ex:516: Module.eval_quoted/4
The hot fix was uninstalling ElixirLS and reinstalling it, but @michalmuskala and I thought it might be worth filing an issue here. Thanks!
Metadata
Metadata
Assignees
Labels
No labels