Fix dialyzer warning in Code.format_string!/2 (#14928)
* Fix dialyzer warning in Code.format_string!/2 Tentative fix for https://github.com/elixir-lang/elixir/issues/14927 * Add regression test for IO.inspect/2 opts
This commit is contained in:
@@ -1090,7 +1090,7 @@ defmodule Code do
|
||||
@doc since: "1.6.0"
|
||||
@spec format_string!(binary, [format_opt]) :: iodata
|
||||
def format_string!(string, opts \\ []) when is_binary(string) and is_list(opts) do
|
||||
line_length = Keyword.get(opts, :line_length, 98)
|
||||
{line_length, opts} = Keyword.pop(opts, :line_length, 98)
|
||||
|
||||
to_quoted_opts =
|
||||
[
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
defmodule Dialyzer.Regressions do
|
||||
def io_inspect_opts do
|
||||
IO.inspect(123, label: "foo", limit: :infinity)
|
||||
end
|
||||
|
||||
def format_opts do
|
||||
Code.format_string!("",
|
||||
line_length: 120,
|
||||
force_do_end_blocks: true,
|
||||
locals_without_parens: true,
|
||||
migrate: true
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -185,6 +185,11 @@ defmodule Kernel.DialyzerTest do
|
||||
assert_dialyze_no_warnings!(context)
|
||||
end
|
||||
|
||||
test "no warning in various non-regression cases", context do
|
||||
copy_beam!(context, Dialyzer.Regressions)
|
||||
assert_dialyze_no_warnings!(context)
|
||||
end
|
||||
|
||||
defp copy_beam!(context, module) do
|
||||
name = "#{module}.beam"
|
||||
File.cp!(Path.join(context.base_dir, name), Path.join(context.outdir, name))
|
||||
|
||||
Reference in New Issue
Block a user