Skip to content

Fix return_diagnostics warning from Kernel.ParallelCompiler on Elixir 1.19+#317

Open
markszabo wants to merge 1 commit into
antonmi:mainfrom
markszabo:patch-1
Open

Fix return_diagnostics warning from Kernel.ParallelCompiler on Elixir 1.19+#317
markszabo wants to merge 1 commit into
antonmi:mainfrom
markszabo:patch-1

Conversation

@markszabo

Copy link
Copy Markdown

Running mix espec on Elixir 1.19 prints the following warning on every run, before any specs execute:

warning: you must pass return_diagnostics: true when invoking Kernel.ParallelCompiler functions
  (elixir 1.19.5) lib/kernel/parallel_compiler.ex:324: Kernel.ParallelCompiler.spawn_workers/3
  (espec 1.10.0) lib/mix/tasks/espec.ex:225: Mix.Tasks.Espec.parse_spec_files/2
  (espec 1.10.0) lib/mix/tasks/espec.ex:160: Mix.Tasks.Espec.run_espec/3
  (espec 1.10.0) lib/mix/tasks/espec.ex:140: Mix.Tasks.Espec.run/1
  (mix 1.19.5) lib/mix/task.ex:499: anonymous fn/3 in Mix.Task.run_task/5
  (mix 1.19.5) lib/mix/cli.ex:129: Mix.CLI.run_task/2

Elixir 1.19 made return_diagnostics: true mandatory for callers of Kernel.ParallelCompiler functions. The compile/2 call in lib/mix/tasks/espec.ex doesn't have this, and this PR adds it.

Backward compatibility

Safe on all Elixir versions:

  • 1.19+ - fixes the warning
  • 1.15–1.18 - return_diagnostics: true was introduced in 1.15.0 and silently accepted; it was only recommended, not required, so no warning was emitted
  • < 1.15 - Kernel.ParallelCompiler.compile/2 accepts an open keyword list and reads options via Keyword.get. An unrecognised key is simply never read; no error or warning is raised

Though I only tested it on 1.19.

With return_diagnostics: true the third element of the return tuple changes shape, but espec's call-site only pattern-matches on {:error, _, _} and discards the third element, so this has no effect on behavior.

@zhabinka

Copy link
Copy Markdown

+1

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.

2 participants