Skip to content

Commit e710ace

Browse files
committed
Fix dialyzer warning in Code.format_string!/2
Tentative fix for #14927
1 parent 1b92f3a commit e710ace

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

lib/elixir/lib/code.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ defmodule Code do
10901090
@doc since: "1.6.0"
10911091
@spec format_string!(binary, [format_opt]) :: iodata
10921092
def format_string!(string, opts \\ []) when is_binary(string) and is_list(opts) do
1093-
line_length = Keyword.get(opts, :line_length, 98)
1093+
{line_length, opts} = Keyword.pop(opts, :line_length, 98)
10941094

10951095
to_quoted_opts =
10961096
[
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
defmodule Dialyzer.Regressions do
2+
def format_opts do
3+
Code.format_string!("",
4+
line_length: 120,
5+
force_do_end_blocks: true,
6+
locals_without_parens: true,
7+
migrate: true
8+
)
9+
end
10+
end

lib/elixir/test/elixir/kernel/dialyzer_test.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ defmodule Kernel.DialyzerTest do
185185
assert_dialyze_no_warnings!(context)
186186
end
187187

188+
test "no warning in various non-regression cases", context do
189+
copy_beam!(context, Dialyzer.Regressions)
190+
assert_dialyze_no_warnings!(context)
191+
end
192+
188193
defp copy_beam!(context, module) do
189194
name = "#{module}.beam"
190195
File.cp!(Path.join(context.base_dir, name), Path.join(context.outdir, name))

0 commit comments

Comments
 (0)