Fix Elixir 1.20 compile warnings#1865
Merged
Flo0807 merged 11 commits intonaymspace:developfrom Mar 27, 2026
Merged
Conversation
d8ca20b to
63f9583
Compare
63f9583 to
ae1cd92
Compare
Flo0807
reviewed
Mar 27, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR targets Elixir 1.20 compile-time warnings in Backpex consumers by changing how Backpex injects default callback implementations, and by cleaning up a few redundant module directives. It also updates the demo app to address Elixir 1.20 test-macro type warnings and a Finch dependency divergence.
Changes:
- Move several default callback implementations from
__before_compile__into__using__, and mark themdefoverridable(Backpex.LiveResource / Backpex.Field / Backpex.ItemAction). - Remove redundant
require/usestatements that are no longer needed. - Update demo LiveResources/tests to work cleanly under Elixir 1.20 and add a direct Finch dependency to address dependency divergence.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/backpex_web.ex | Removes redundant use Phoenix.Component from the :field helper. |
| lib/backpex/live_resource/show.ex | Removes unused require Backpex. |
| lib/backpex/live_resource.ex | Moves default LiveResource callback implementations into __using__ and adds defoverridable to support overrides without redundant-clause warnings. |
| lib/backpex/item_actions/item_action.ex | Moves default ItemAction callback implementations into __using__ and adds defoverridable; keeps __before_compile__ for validation. |
| lib/backpex/html/core_components.ex | Removes unused require Backpex. |
| lib/backpex/field.ex | Moves default Field callback implementations into __using__ and adds defoverridable; leaves render injection in __before_compile__. |
| demo/test/support/live_resource_tests.ex | Reworks success-message branching in test macros to avoid Elixir 1.20 type warnings. |
| demo/mix.exs | Adds a direct Finch dependency intended to address diverged dependency requirements. |
| demo/lib/demo_web/live/user_live.ex | Adds a translate/1 fallback clause delegating to super/1 to preserve defaults while customizing translations. |
| demo/lib/demo_web/live/short_link_live.ex | Adds a return_to/5 fallback clause delegating to super/5 to preserve defaults alongside a specific override. |
| demo/lib/demo_web/live/film_review_live.ex | Adds a render_resource_slot/3 fallback clause delegating to super/3 to preserve defaults alongside a specific slot override. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apologies in advance as the diff is larger than I'd hoped, though it is mostly one core issue. There are a handful of redundant requires/use statements that I've removed. The bulk of the changes are because when compiling an app that uses Backpex and Elixir 1.20, a number of compile warnings will be returned:
It seems to mostly be due to Backpex defining the methods in before_compile, which results in the dependent module potentially defining conflicting functions and the warning. This applies to
Backpex.Field,Backpex.ItemAction, andBackpex.LiveResource. To try to address it, I've moved the default function definitions out of__before_compile__and into__using__with correspondingdefoverridableadditions so the methods can be overridden. There is a wrinkle to this for functions that need to fall back to the default. They would need to add a fallback function definition that callssuper(). Ex:I'm not sure if this would be the preferred approach, but am happy to make changes to accommodate the best path here.
The tests also fail under Elixir 1.20 due to the test macros always evaluating conditionals as true or false, so I've tried to address that as well:
Example Warning
The finch commit is mostly unrelated, but addresses an issue with diverged dependencies in the demo app:
Example Warning
Thanks again!