patch icon indicating copy to clipboard operation
patch copied to clipboard

`String.slice` deprecation in Elixir 1.16.0 yields warning

Open josephineweidner opened this issue 1 year ago • 1 comments

From Elixir changelog for 1.16:

  1. 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
...

josephineweidner avatar Feb 01 '24 19:02 josephineweidner

I've opened #60 to address this.

lucacorti avatar Feb 02 '24 20:02 lucacorti

This should now be corrected in release v0.13.1

ihumanable avatar May 03 '24 00:05 ihumanable