Skip to content

Support Elixir 1.20#47

Open
BobbieBarker wants to merge 1 commit into
MikaAK:mainfrom
BobbieBarker:chore/elixir-1.20-upgrade
Open

Support Elixir 1.20#47
BobbieBarker wants to merge 1 commit into
MikaAK:mainfrom
BobbieBarker:chore/elixir-1.20-upgrade

Conversation

@BobbieBarker
Copy link
Copy Markdown
Contributor

@BobbieBarker BobbieBarker commented Jun 4, 2026

What

Adds Elixir 1.20 support and clears the new compiler/type-system warnings so the project builds clean under --warnings-as-errors.

Changes

  • Cache.__using__ macro — 1.20's type checker flagged two patterns in the generated code:
    • adapter_options!/1 emitted an unconditional catch-all that became dead whenever a shape-specific clause was generated. Now emits exactly one clause per compile-time adapter-opts shape.
    • The generated get/1 had a {:error, _} clause that 1.20 proves unreachable for adapters whose get can't error. Replaced with a catch-all that still passes errors through unchanged for adapters that can (e.g. Redis). Behavior is identical.
  • Cache.ETS — removed the module-level require Cache.OTPVersion (unused; the macro call sites live inside __using__, which requires it itself).
  • mix.exs — moved :preferred_cli_env into def cli (the old form is deprecated in 1.20); bumped the Elixir floor to ~> 1.15.
  • Dropped the :faker test dependency. It no longer compiles on 1.20 — a raw U+0085 byte in its source is now a hard syntax error, and the project is unmaintained. It was only used for three random-string helpers, now replaced by a small test/support/gen.ex.

Testing

mix test passes under 1.20 (full suite green with the CI Redis service).

🤖 Generated with Claude Code

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.81%. Comparing base (7ad44ee) to head (7f28add).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #47      +/-   ##
==========================================
+ Coverage   83.49%   83.81%   +0.32%     
==========================================
  Files          23       23              
  Lines         636      655      +19     
==========================================
+ Hits          531      549      +18     
- Misses        105      106       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Add Elixir 1.20 compatibility and clear the new compiler/type-system
warnings under `--warnings-as-errors`:

- Cache.__using__: emit a single adapter_options!/1 clause per adapter
  shape so the catch-all is never a dead clause, and drop the now-dead
  `{:error, _}` branches in generated get/1 (handle_adapter_result is
  typed to never return an error for non-erroring adapters).
- Cache.ETS: remove module-level `require Cache.OTPVersion` (only used
  inside __using__, which requires it itself).
- mix.exs: move :preferred_cli_env into `def cli`, bump elixir to ~> 1.15.

Update the test toolchain for 1.20:

- Bump :credo 1.7.13 -> 1.7.18; 1.7.13 crashes on 1.20's new sigil token
  format. The newer Credo surfaced one expensive `length/1 > 0` check,
  rewritten as `!== []`.
- Drop the unmaintained :faker test dependency, which fails to compile on
  1.20 (raw U+0085 byte is now a hard syntax error). It was only used for
  three random-string helpers; replaced with a small test/support module.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@BobbieBarker BobbieBarker force-pushed the chore/elixir-1.20-upgrade branch from 853ebee to 7f28add Compare June 4, 2026 00:59
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