8000 Pin operators added to matching inside the frame module by Cinderella-Man · Pull Request #142 · dominicletz/websockex · GitHub
[go: up one dir, main page]

Skip to content

Pin operators added to matching inside the frame module - #142

Merged
dominicletz merged 1 commit into
dominicletz:masterfrom
Cinderella-Man:master
Oct 22, 2026
Merged

dominicletz merged 1 commit into
dominicletz:masterfrom
Cinderella-Man:master

Conversation

@Cinderella-Man
Copy link
Copy Markdown
Contributor

Hello 👋

I'm getting the below warnings in Elixir 1.20.0-rc.1:

==> websockex
Compiling 6 files (.ex)
     warning: the variable "size" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 109 │     <<payload::bytes-size(size), rest::bitstring>> = remaining
     │                           ~
     │
     └─ lib/websockex/frame.ex:109:27: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 125 │       <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                             ~
     │
     └─ lib/websockex/frame.ex:125:29: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 125 │       <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                             ~
     │
     └─ lib/websockex/frame.ex:125:29: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 145 │     <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                           ~
     │
     └─ lib/websockex/frame.ex:145:27: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 150 │     <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                           ~
     │
     └─ lib/websockex/frame.ex:150:27: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 155 │     <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                           ~
     │
     └─ lib/websockex/frame.ex:155:27: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 164 │       <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                             ~
     │
     └─ lib/websockex/frame.ex:164:29: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 171 │       <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                             ~
     │
     └─ lib/websockex/frame.ex:171:29: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 176 │       <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                             ~
     │
     └─ lib/websockex/frame.ex:176:29: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 164 │       <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                             ~
     │
     └─ lib/websockex/frame.ex:164:29: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 171 │       <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                             ~
     │
     └─ lib/websockex/frame.ex:171:29: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 176 │       <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                             ~
     │
     └─ lib/websockex/frame.ex:176:29: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 183 │     <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                           ~
     │
     └─ lib/websockex/frame.ex:183:27: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 188 │     <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                           ~
     │
     └─ lib/websockex/frame.ex:188:27: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 193 │     <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                           ~
     │
     └─ lib/websockex/frame.ex:193:27: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 199 │     <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                           ~
     │
     └─ lib/websockex/frame.ex:199:27: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 204 │     <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                           ~
     │
     └─ lib/websockex/frame.ex:204:27: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 209 │     <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                           ~
     │
     └─ lib/websockex/frame.ex:209:27: WebSockex.Frame.parse_frame/1

     warning: the variable "len" is accessed inside size(...) of a bitstring but it was defined outside of the match. You must precede it with the pin operator
     │
 358 │     <<payload::bytes-size(len), rest::bitstring>> = remaining
     │                           ~
     │
     └─ lib/websockex/frame.ex:358:27: WebSockex.Frame.parse_text_payload/3

So I have updated the code as suggested by the compiler, resulting in the above warnings disappearing.

I hope this makes sense - I've briefly manually tested the package(after the change) and it appears to be still working / receiving data

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @Cinderella-Man, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request updates the websockex library to resolve compiler warnings encountered with Elixir 1.20.0-rc.1. The changes involve modifying bitstring pattern matching syntax by adding pin operators to variables used within size specifications, ensuring compatibility with newer Elixir versions while maintaining the existing parsing logic for WebSocket frames.

Highlights

  • Compiler Warning Resolution: Addressed and resolved multiple compiler warnings that appeared in Elixir 1.20.0-rc.1 related to variable usage within bitstring pattern matching.
  • Pin Operator Implementation: Introduced the pin operator (^) to size and len variables in bitstring pattern matches across various parse_frame and parse_text_payload functions in lib/websockex/frame.ex.
  • Functional Verification: Manually tested the package after the changes to confirm that it continues to function correctly and receive data as expected.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist fo 8000 r GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses several compiler warnings from newer Elixir versions by correctly using the pin operator ^ in bitstring pattern matches within the WebSockex.Frame module. The changes are accurate, minimal, and necessary for compatibility and to avoid potential bugs where variables could be rebound instead of matched against. The code is now cleaner and free of these warnings. Great job on this proactive fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0