Skip to content

Fix compilation warnings#210

Open
gilbertwong96 wants to merge 2 commits into
elixir-ecto:masterfrom
gilbertwong96:fix/compilation-warnings
Open

Fix compilation warnings#210
gilbertwong96 wants to merge 2 commits into
elixir-ecto:masterfrom
gilbertwong96:fix/compilation-warnings

Conversation

@gilbertwong96

@gilbertwong96 gilbertwong96 commented Jun 13, 2026

Copy link
Copy Markdown

Summary

Cleans up the 7 compilation warnings emitted by mix compile on the current Elixir toolchain. Also picks up the dev/test dependency bumps auto-resolved by mix deps.get.

Warning fixes (commit 1)

The Elixir compiler warns whenever a variable used in a bitstring size specifier is defined outside the match itself:

warning: the variable "X" is accessed inside size(...) of a bitstring but it was
defined outside of the match. You must precede it with the pin operator

Per the Elixir docs the canonical fix is the pin operator. Six bitstring segments and one require directive are touched:

File Change
lib/myxql/protocol.ex (encode_packet/4) size(max_packet_size)size(^max_packet_size)
lib/myxql/protocol.ex (decode_initial_handshake/1) binary-size(take)binary-size(^take)
lib/myxql/protocol/types.ex (take_string_lenenc/1) string(size)string(^size)
lib/myxql/protocol/values.ex (decode_binary_row/2) uint(size)uint(^size)
lib/myxql/protocol/values.ex (decode_bit/2) size(pad), size(size)size(^pad), size(^size)
lib/myxql/protocol/auth.ex drop unused require Bitwise (the file's TODO said to drop it once we require Elixir 1.10+; mix.exs already declares ~> 1.13)

Semantics are unchanged — the pin operator in a bitstring size position is purely a syntactic clarification. mix compile --warnings-as-errors passes cleanly.

Dependency updates (commit 2)

mix.lock was updated to the latest versions allowed by the ranges in mix.exs. The geo upgrade from 3.4.0 → 4.1.0 is already supported by the existing ~> 3.4 or ~> 4.0 requirement. Per the geo 4.0.0 changelog, the breaking changes are confined to Geo.JSON (SRID defaults to 4326; string coordinates coerced to numbers); myxql uses Geo.WKB exclusively, so the upgrade is transparent here. No code changes needed for any of the dep updates.

Test plan

  • mix compile --warnings-as-errors passes with no warnings in myxql
  • MIX_ENV=test mix compile passes with no warnings in myxql
  • CI (geometry-tagged tests in test/myxql/protocol/values_test.exs)

The Elixir compiler warns when a variable used in a bitstring size
specifier is defined outside the match. The compiler instructs the
author to pin the variable with the ^ operator so it is clear that the
existing binding is being matched against, not a new one being bound.

Apply the pin operator to the 6 affected bitstring segments:

  * lib/myxql/protocol.ex
    - encode_packet/4: pin max_packet_size in size(^max_packet_size)
    - decode_initial_handshake/1: pin take in binary-size(^take)
  * lib/myxql/protocol/types.ex
    - take_string_lenenc/1: pin size in string(^size)
  * lib/myxql/protocol/values.ex
    - decode_binary_row/2: pin size in uint(^size)
    - decode_bit/2: pin both pad and size in size(^pad), size(^size)

Also drop the unused 'require Bitwise' from MyXQL.Protocol.Auth. All
call sites in the codebase use the fully-qualified Bitwise.bxor/band/bor
form, so the require is dead. The original TODO comment said to remove
it once Elixir 1.10+ is required; mix.exs declares 'elixir: ~> 1.13',
so that bar is cleared.

Behaviour is unchanged: the pin operator in a bitstring size position
is purely a syntactic clarification. mix compile --warnings-as-errors
passes cleanly.
Auto-resolved by mix deps.get to the latest versions allowed by the
ranges declared in mix.exs. Notable updates:

  * geo 3.4.0 -> 4.1.0 (already supported: '~> 3.4 or ~> 4.0')
  * db_connection 2.4.1 -> 2.10.1
  * decimal 3.0.0 -> 3.1.1
  * dialyxir 1.0.0 -> 1.4.7
  * benchee 1.0.1 -> 1.5.1 (pulls in new dev dep statistex 1.1.1)
  * telemetry 1.0.0 -> 1.4.2
  * ex_doc 0.40.1 -> 0.40.3
  * erlex 0.2.6 -> 0.2.9
  * deep_merge 1.0.0 -> 1.0.2
  * table 0.1.0 -> 0.1.2
  * makeup_erlang 1.0.3 -> 1.1.0

No code changes required for any of these. mix compile passes with no
warnings after the previous commit's warning fixes.
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.

1 participant