-
Notifications
You must be signed in to change notification settings - Fork 238
Description
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 inparse_param/2functionslib/grpc/protoc/generator.ex- 1 warning ingenerate_module_definitions/2
grpc_client
lib/grpc/client/connection.ex- 4 warnings inbuild_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
-
Test type warning:
grpc_server/test/grpc/server/adapters/report_exception_test.exs:20has an unreachable:errorclause that triggers a type warning -
Test file naming:
grpc_client/test/grpc/integration/erlpack_notypes.exuses.exextension 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