Skip to content

Fix two compile warnings under Elixir 1.20 - #143

Open
themiguelamador wants to merge 1 commit into
mathieuprog:masterfrom
themiguelamador:fix/elixir-1.20-warnings
Open

themiguelamador wants to merge 1 commit into
mathieuprog:masterfrom
themiguelamador:fix/elixir-1.20-warnings

Conversation

@themiguelamador

Copy link
Copy Markdown

Two compile warnings appear with Elixir 1.20's type checker (5.0.6 and current master):

warning: unused require PolymorphicEmbed.OptionsValidator
warning: incompatible types given as default arguments to polymorphic_embed_inputs_for/4
  • lib/polymorphic_embed.ex: the require is unused, because OptionsValidator is only called through its alias. Removed.
  • lib/polymorphic_embed/html/form.ex: polymorphic_embed_inputs_for(form, field, type \\ nil, fun)'s default generates a 3-arity head that can never be reached. An explicit polymorphic_embed_inputs_for(form, field, fun) clause is defined just above it. Removed the default.

No behaviour change: 3-arity calls already resolve to the explicit clause.

Verified on Elixir 1.20.3 / OTP 28: both warnings are gone after mix compile --force, and mix test passes (77 tests).

- Remove the unused `require PolymorphicEmbed.OptionsValidator`: the module is
  only called through its alias (`OptionsValidator.validate!/1`), never as a macro.
- Drop the `\\ nil` default on `polymorphic_embed_inputs_for/4`. The default
  generates a 3-arity head that is unreachable, because an explicit
  `polymorphic_embed_inputs_for(form, field, fun)` clause already exists; Elixir
  1.20's type checker reports it as "incompatible types given as default
  arguments". No behaviour change: 3-arity calls already resolve to that clause.
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

Successfully merging this pull request may close these issues.

1 participant