Commit 0c630f7
committed
Fix Elixir 1.20.0-rc.0 warnings
Mainly this involves using the pin operator (`^`) in binary pattern
matches where the size is matched out of a binary.
`Mint.WebSocket.Frame.decode_opcode/1` is also refactored to pattern
match the map directly, resolving this warning:
warning: incompatible types given to Map.fetch/2:
Map.fetch(
%{
<<0::integer-size(4), ""::binary>> => :continuation,
<<1::integer-size(4), ""::binary>> => :text,
<<2::integer-size(4), ""::binary>> => :binary,
<<8::integer-size(4), ""::binary>> => :close,
<<9::integer-size(4), ""::binary>> => :ping,
<<10::integer-size(4), ""::binary>> => :pong
},
opcode
)
the map:
dynamic(%{bitstring() => :binary or :close or :continuation or :ping or :pong or :text})
does not have all required keys:
dynamic()
therefore this function will always return :error
where "opcode" was given the type:
# type: dynamic()
# from: lib/mint/web_socket/frame.ex:289:22
opcode
typing violation found at:
│
290 │ with :error <- Map.fetch(@reverse_opcodes, opcode) do
│ ~
│
└─ lib/mint/web_socket/frame.ex:290:24: Mint.WebSocket.Frame.decode_opcode/11 parent ab070d4 commit 0c630f7
File tree
4 files changed
+10
-9
lines changed- .github/workflows
- lib/mint/web_socket
4 files changed
+10
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | | - | |
| 268 | + | |
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
291 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
292 | 293 | | |
293 | 294 | | |
294 | 295 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
0 commit comments