Skip to content

Elixir 1.19 compatibility: struct update type warnings and test file naming #489

@nshkrdotcom

Description

@nshkrdotcom

Environment

  • Elixir 1.19.4-otp-28
  • OTP 28

Description

Compiling on Elixir 1.19 produces numerous "typing violation" warnings due to the new gradual type system's stricter handling of struct updates. The compiler now requires explicit pattern matching to verify a variable's struct type before using struct update syntax.

Warnings

When running mix compile, the following warnings appear:

grpc_server

  • lib/grpc/protoc/cli.ex - 6 warnings in parse_param/2 functions
  • lib/grpc/protoc/generator.ex - 1 warning in generate_module_definitions/2

grpc_client

  • lib/grpc/client/connection.ex - 4 warnings in build_balanced_state/6, build_direct_state/4, build_real_channels/4, connect_real_channel/5

Example warning:
warning: a struct for Protobuf.Protoc.Context is expected on struct update:

%Protobuf.Protoc.Context{ctx | plugins: String.split(plugins, "+")}
but got type:

dynamic()
when defining the variable "ctx", you must also pattern match on "%Protobuf.Protoc.Context{}".

Additional Issues

  1. Test type warning: grpc_server/test/grpc/server/adapters/report_exception_test.exs:20 has an unreachable :error clause that triggers a type warning

  2. Test file naming: grpc_client/test/grpc/integration/erlpack_notypes.ex uses .ex extension instead of _test.exs, causing Mix to emit a warning about files not matching test patterns

Expected Fix

Add explicit struct pattern matches to function parameters per Elixir 1.19 type system requirements:

# Before
defp parse_param("plugins=" <> plugins, ctx) do

# After
defp parse_param("plugins=" <> plugins, %Context{} = ctx) do

References

- http://elixir-lang.org/blog/2025/10/16/elixir-v1-19-0-released/
- https://hexdocs.pm/elixir/gradual-set-theoretic-types.html

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions