Skip to content

phoenixframework/phoenix

Back Fix Elixir 1.15 compiler warnings (#6828)

Commit details

Fix Elixir 1.15 compiler warnings (#6828)

Description

Address compiler warnings emitted in `Phoenix.CodeReloader.Server` when compiling Phoenix on Elixir < 1.19 (such as Elixir 1.15 on CI): - What: Replace the `@requires_consolidation` module attribute with version-gated helper functions. - Why: On Elixir < 1.19 (e.g. 1.15.8), `@requires_consolidation` evaluated to `true` at compile time. Using it in `&&` checks inside `if` and `cond` clauses triggered "this check/guard will always yield the same result" compiler warnings. - Tradeoff: Adds a couple of small conditionally defined private functions instead of inline attribute checks, cleanly isolating version branching and eliminating boolean literal warnings in Phoenix core. Note on installer `JSON.decode!/1` warning: When running the root test suite on Elixir 1.15 in CI, compiling `Mix.Tasks.Phx.New` emits an undefined module warning for `JSON.decode!/1` (introduced in Elixir 1.18). We intentionally omit conditional shims in `installer/` because `phx_new` officially requires Elixir ~> 1.18 and is never installed or executed on older Elixir versions in production. CI enforces `--warnings-as-errors` on the latest Elixir version, so this test-only warning on older matrix runs is accepted to keep the installer codebase clean.

Metadata

Author
Rodolfo Carvalho rhcarvalho@gmail.com
Committed
Commit

Contributors

  • Rodolfo Carvalho rhcarvalho@gmail.com Author