-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
Elixir and Erlang/OTP versions
Erlang/OTP 27 [erts-15.1.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
Elixir 1.18.0-rc.0 (compiled with Erlang/OTP 27)
Operating system
macOS
Current behavior
After upgrading from 1.17.3 to 1.18.0-rc.0, I'm seeing this warning message:
.warning: Range.new/2 has a default step of -1, please call Range.new/3 explicitly passing the step of -1 instead
(flop_phoenix 0.23.1) lib/flop_phoenix.ex:502: Flop.Phoenix."page_links (overridable 1)"/1
(phoenix_live_view 1.0.0) lib/phoenix_live_view/tag_engine.ex:96: Phoenix.LiveView.TagEngine.component/3
(flop_phoenix 0.23.1) lib/flop_phoenix.ex:477: anonymous fn/2 in Flop.Phoenix."pagination (overridable 1)"/1
(phoenix_live_view 1.0.0) lib/phoenix_live_view/engine.ex:149: Phoenix.HTML.Safe.Phoenix.LiveView.Rendered.to_iodata/1
(phoenix_live_view 1.0.0) lib/phoenix_live_view/engine.ex:165: Phoenix.HTML.Safe.Phoenix.LiveView.Rendered.to_iodata/3
(phoenix_html 4.1.1) lib/phoenix_html.ex:134: Phoenix.HTML.html_escape/1
(phoenix_live_view 1.0.0) lib/phoenix_live_view/test/live_view_test.ex:518: Phoenix.LiveViewTest.rendered_to_string/1
(flop_phoenix 0.23.1) test/support/test_helpers.ex:23: Flop.Phoenix.TestHelpers.parse_heex/1
test/flop_phoenix_test.exs:589: Flop.PhoenixTest."test pagination/1 doesn't render pagination links if set to hide when passing event"/1
(ex_unit 1.18.0-rc.0) lib/ex_unit/runner.ex:511: ExUnit.Runner.exec_test/2
(stdlib 6.1.2) timer.erl:590: :timer.tc/2
(ex_unit 1.18.0-rc.0) lib/ex_unit/runner.ex:433: anonymous fn/6 in ExUnit.Runner.spawn_test_monitor/4
This is occurring on the main branch of Flop Phoenix.
git clone git@github.com:woylie/flop_phoenix.git
cd flop_phoenix
git checkout f0d145dbef77c0e41b3cde6ce3e84d2e3e6f6e26
mix deps.get
mix testThe referenced line 502 contains a call to the library function get_page_link_range (a range is matched on one line prior). Range.new/2 is not called.
range =
first..last//_ =
Pagination.get_page_link_range(
meta.current_page,
max_pages,
meta.total_pages
)The called function builds ranges like this:
def get_page_link_range(current_page, max_pages, total_pages) do
# number of additional pages to show before or after current page
additional = ceil(max_pages / 2)
cond do
max_pages >= total_pages ->
1..total_pages
current_page + additional > total_pages ->
(total_pages - max_pages + 1)..total_pages
true ->
first = max(current_page - additional + 1, 1)
last = min(first + max_pages - 1, total_pages)
first..last
end
endThe warning disappears after changing the code in that function to 1..total_pages//1 etc.
Expected behavior
I'd expect the warning message to a) point to the file and line that causes the issue, b) explain the issue using the range syntax instead of mentioning Range.new, and c) not tell me to pass -1 although no negative range is used.