From a86664b3b692d3354fcb9d6b1143ab70e1ffad20 Mon Sep 17 00:00:00 2001 From: Matt Enlow Date: Thu, 20 Feb 2025 13:28:08 -0700 Subject: [PATCH] ship struct update to map update changes after all --- lib/style/deprecations.ex | 7 +++---- test/style/deprecations_test.exs | 12 ++++-------- test/style/pipes_test.exs | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/style/deprecations.ex b/lib/style/deprecations.ex index d7f259e..7e920c4 100644 --- a/lib/style/deprecations.ex +++ b/lib/style/deprecations.ex @@ -66,10 +66,9 @@ defmodule Quokka.Style.Deprecations do end end - if Version.match?(System.version(), ">= 1.19.0-dev") do - # Struct update syntax was deprecated `%Foo{x | y} => %{x | y}` - defp style({:%, _, [_struct, {:%{}, _, [{:|, _, _}]} = update]}), do: update - end + # Struct update syntax is deprecated in 1.19 + # `%Foo{x | y} => %{x | y}` + defp style({:%, _, [_struct, {:%{}, _, [{:|, _, _}]} = update]}), do: update # For ranges where `start > stop`, you need to explicitly include the step # Enum.slice(enumerable, 1..-2) => Enum.slice(enumerable, 1..-2//1) diff --git a/test/style/deprecations_test.exs b/test/style/deprecations_test.exs index 28d0f97..5201f2a 100644 --- a/test/style/deprecations_test.exs +++ b/test/style/deprecations_test.exs @@ -129,6 +129,10 @@ defmodule Quokka.Style.DeprecationsTest do end end + test "struct update, deprecated in 1.19" do + assert_style "%Foo{widget | bar: :baz}", "%{widget | bar: :baz}" + end + describe "1.16+" do @describetag skip: Version.match?(System.version(), "< 1.16.0-dev") @@ -158,12 +162,4 @@ defmodule Quokka.Style.DeprecationsTest do assert_style "a |> x() |> :timer.seconds()" end end - - describe "1.19+" do - @describetag skip: Version.match?(System.version(), "< 1.19.0-dev") - - test "struct update" do - assert_style "%Foo{widget | bar: :baz}", "%{widget | bar: :baz}" - end - end end diff --git a/test/style/pipes_test.exs b/test/style/pipes_test.exs index baa6294..a5c5df6 100644 --- a/test/style/pipes_test.exs +++ b/test/style/pipes_test.exs @@ -683,7 +683,7 @@ defmodule Quokka.Style.PipesTest do assert_style(""" def halt(exec, halt_message) do - %__MODULE__{exec | halted: true} + %{exec | halted: true} |> put_halt_message(halt_message) end """)