Skip to content

Commit 87f5ce4

Browse files
committed
minor: Use literal list syntax instead of a descending range
This removes a warning from `4..1` present in Elixir 1.17+. We don't switch to `4..1//-1` so that we can maintain compatibility with Elixir versions before the range-step syntax was introduced.
1 parent 05881b3 commit 87f5ce4

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ The format is based on [Keep a
66
Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
77
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## Unreleased
10+
11+
### Fixed
12+
13+
- Fixed a compilation warning present with Elixir 1.17+ about "`4..1`" not
14+
using a range step.
15+
916
## 1.0.3 - 2023-04-16
1017

1118
### Fixed

lib/mint/web_socket/frame.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ defmodule Mint.WebSocket.Frame do
183183
# n=4 is the happy path
184184
# n=3..1 catches cases where the remaining byte_size/1 of the payload is shorter
185185
# than the mask
186-
for n <- 4..1 do
186+
# MINOR: We use a literal list instead of `4..1` to avoid compilation warnings on
187+
# Elixir 1.17+ and instead of `4..1//-1` to maintain compatibility with older
188+
# Elixir versions that do not support the range-step syntax.
189+
for n <- [4, 3, 2, 1] do
187190
def apply_mask(
188191
<<part_key::integer-size(8)-unit(unquote(n)), payload_rest::binary>>,
189192
<<mask_key::integer-size(8)-unit(unquote(n)), _::binary>> = mask,

0 commit comments

Comments
 (0)