Skip to content

elixir-1.19.2 "def application" has a term which cannot be written to .app files: &Mod.fun/0 #14891

@juulSme

Description

@juulSme

Elixir and Erlang/OTP versions

Elixir 1.19.2 (both source-compiled and the precompiled version of GH Actions with OTP 27)
Erlang 27.3.4.4 (same)

Operating system

Linux (Fedora 42 and GH Actions' Ubuntu 24)

Current behavior

I have a project that compiles perfectly fine with Elixir 1.19.1, but fails to compile with 1.19.2. As far as I can tell from reading the release notes of 1.19.0-2 there's been no hard deprecation that should cause a problem.

==> ritsplit
Compiling 114 files (.ex)
** (Mix) "def application" has a term which cannot be written to .app files: &RitsplitWeb.Charon.get_base_secret/0

The function capture is defined in config.exs as:

config :ritsplit, :charon,
  get_base_secret: &RitsplitWeb.Charon.get_base_secret/0,
  ...

It is then set as a module attribute in a module Ritsplit.Charon, to be returned from a config/0 function:

defmodule RitsplitWeb.Charon do
  # from_enum/1 returns a struct
  @config Application.compile_env!(:ritsplit, :charon) |> Charon.Config.from_enum()

  def config, do: @config
end

Rewriting to omit the module attribute fixes the issue:

defmodule RitsplitWeb.Charon do
  def config, do: Application.get_env(:ritsplit, :charon) |> Charon.Config.from_enum()
end

As far as I know, the previous code is valid.

Expected behavior

I expect it to work :p

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions