patch
patch copied to clipboard
`String.slice` deprecation in Elixir 1.16.0 yields warning
From Elixir changelog for 1.16:
- Hard deprecations
-[String] Deprecate passing a range with negative step on String.slice/2, give first..last//1 instead
@doc """
Formats the AST for a list of patterns AST as they would appear in an argument list.
"""
@spec format_patterns(patterns :: [term()]) :: String.t()
defmacro format_patterns(patterns) do
patterns
|> Macro.to_string()
|> String.slice(1..-2)
end
should be:
@doc """
Formats the AST for a list of patterns AST as they would appear in an argument list.
"""
@spec format_patterns(patterns :: [term()]) :: String.t()
defmacro format_patterns(patterns) do
patterns
|> Macro.to_string()
|> String.slice(1..-2//1)
end
Otherwise, warnings will occur when running Elixir 1.16:
warning: negative steps are not supported in String.slice/2, pass 1..-2//1 instead
(elixir 1.16.0) lib/string.ex:2368: String.slice/2
(elixir 1.16.0) src/elixir_dispatch.erl:228: :elixir_dispatch.expand_macro_fun/7
(elixir 1.16.0) src/elixir_dispatch.erl:215: :elixir_dispatch.expand_require/6
(elixir 1.16.0) src/elixir_dispatch.erl:136: :elixir_dispatch.dispatch_require/7
...
I've opened #60 to address this.
This should now be corrected in release v0.13.1