We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d2c9d39 commit 666c082Copy full SHA for 666c082
2 files changed
lib/mix/lib/mix/tasks/compile.app.ex
@@ -239,7 +239,20 @@ defmodule Mix.Tasks.Compile.App do
239
[?#, ?{, inner, ?}]
240
end
241
242
- defp to_erl_term(term) when is_function(term) or is_reference(term) or is_pid(term) do
+ defp to_erl_term(function) when is_function(function) do
243
+ fun_info = Function.info(function)
244
+
245
+ if fun_info[:type] == :external and fun_info[:env] == [] do
246
+ :io_lib.print(function)
247
+ else
248
+ Mix.raise(
249
+ "\"def application\" has a function which cannot be written to .app files: #{inspect(function)}" <>
250
+ " (only functions in the form &Mod.fun/arity can be part of the application environment)"
251
+ )
252
+ end
253
254
255
+ defp to_erl_term(term) when is_reference(term) or is_pid(term) do
256
Mix.raise(
257
"\"def application\" has a term which cannot be written to .app files: #{inspect(term)}"
258
)
lib/mix/test/mix/tasks/compile.app_test.exs
@@ -110,7 +110,7 @@ defmodule Mix.Tasks.Compile.AppTest do
110
test "uses custom application settings" do
111
in_fixture("no_mixfile", fn ->
112
Mix.Project.push(CustomProject)
113
- env = [foo: [:one, "two", 3, 4, "฿"], bar: [{} | %{foo: :bar}]]
+ env = [foo: [:one, "two", 3, 4, "฿", &List.flatten/1], bar: [{} | %{foo: :bar}]]
114
115
Process.put(:application,
116
maxT: :infinity,
@@ -132,7 +132,10 @@ defmodule Mix.Tasks.Compile.AppTest do
132
assert properties[:applications] ==
133
[:kernel, :stdlib, :elixir, :logger, :ex_unit, :example_app, :mix]
134
135
- assert properties[:env] == [foo: [:one, "two", 3, 4, "฿"], bar: [{} | %{foo: :bar}]]
+ assert properties[:env] == [
136
+ foo: [:one, "two", 3, 4, "฿", &List.flatten/1],
137
+ bar: [{} | %{foo: :bar}]
138
+ ]
139
140
refute Keyword.has_key?(properties, :extra_applications)
141
end)
0 commit comments