Skip to content

Conversation

@David-Klemenc
Copy link

@David-Klemenc David-Klemenc commented Jan 22, 2026

Currently elixir v 1.19.5 and 1.20.0-rc.1 give warnings like:

==> exsync
Compiling 7 files (.ex)
    warning: a struct for ExSync.SrcMonitor.State is expected on struct update:

        %ExSync.SrcMonitor.State{state | throttle_timer: nil}

    but got type:

        dynamic()

    where "state" was given the type:

        # type: dynamic()
        # from: lib/exsync/src_monitor.ex:55:45
        state

    when defining the variable "state", you must also pattern match on "%ExSync.SrcMonitor.State{}".

    hint: given pattern matching is enough to catch typing errors, you may optionally convert the struct update into a map update. For example, instead of:

        user = some_function()
        %User{user | name: "John Doe"}

    it is enough to write:

        %User{} = user = some_function()
        %{user | name: "John Doe"}

    typing violation found at:
    │
 57 │     state = %State{state | throttle_timer: nil}
    │             ~
    │
    └─ lib/exsync/src_monitor.ex:57:13: ExSync.SrcMonitor.handle_info/2

P.S. noticed #63 a bit late -> can make another PR just removing:

require Logger

from application.ex ?

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