Skip to content

Commit

Permalink
minor: Use literal list syntax instead of a descending range
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
the-mikedavis committed Jun 2, 2024
1 parent 05881b3 commit 87f5ce4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format is based on [Keep a
Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Fixed

- Fixed a compilation warning present with Elixir 1.17+ about "`4..1`" not
using a range step.

## 1.0.3 - 2023-04-16

### Fixed
Expand Down
5 changes: 4 additions & 1 deletion lib/mint/web_socket/frame.ex
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ defmodule Mint.WebSocket.Frame do
# n=4 is the happy path
# n=3..1 catches cases where the remaining byte_size/1 of the payload is shorter
# than the mask
for n <- 4..1 do
# MINOR: We use a literal list instead of `4..1` to avoid compilation warnings on
# Elixir 1.17+ and instead of `4..1//-1` to maintain compatibility with older
# Elixir versions that do not support the range-step syntax.
for n <- [4, 3, 2, 1] do
def apply_mask(
<<part_key::integer-size(8)-unit(unquote(n)), payload_rest::binary>>,
<<mask_key::integer-size(8)-unit(unquote(n)), _::binary>> = mask,
Expand Down

0 comments on commit 87f5ce4

Please sign in to comment.