Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@axelson
Copy link
Collaborator

@axelson axelson commented Oct 26, 2025

Fixes compilation warnings from using the struct update syntax (which now isn't as necessary because of type inference, although it can still be helpful to make the code more readable)

These were the compilation warnings:

    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:61: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:
   │
63 │     state = %State{state | throttle_timer: nil}
   │             ~
   │
   └─ lib/exsync/src_monitor.ex:63:13: ExSync.SrcMonitor.handle_info/2

    warning: a struct for ExSync.BeamMonitor.State is expected on struct update:

        %ExSync.BeamMonitor.State{
          state
          | reload_set: MapSet.put(reload_set, module),
            unload_set: MapSet.delete(unload_set, module)
        }

    but got type:

        dynamic()

    where "state" was given the type:

        # type: dynamic()
        # from: lib/exsync/beam_monitor.ex:99:52
        state

    when defining the variable "state", you must also pattern match on "%ExSync.BeamMonitor.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:
    │
102 │     %State{
    │     ~
    │
    └─ lib/exsync/beam_monitor.ex:102:5: ExSync.BeamMonitor.track_module_change/3

    warning: a struct for ExSync.BeamMonitor.State is expected on struct update:

        %ExSync.BeamMonitor.State{
          state
          | reload_set: MapSet.delete(reload_set, module),
            unload_set: MapSet.put(unload_set, module)
        }

    but got type:

        dynamic()

    where "state" was given the type:

        # type: dynamic()
        # from: lib/exsync/beam_monitor.ex:109:52
        state

    when defining the variable "state", you must also pattern match on "%ExSync.BeamMonitor.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:
    │
112 │     %State{
    │     ~
    │
    └─ lib/exsync/beam_monitor.ex:112:5: ExSync.BeamMonitor.track_module_change/3

These were the compilation warnings:
 ```
     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:61: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:
    │
 63 │     state = %State{state | throttle_timer: nil}
    │             ~
    │
    └─ lib/exsync/src_monitor.ex:63:13: ExSync.SrcMonitor.handle_info/2

     warning: a struct for ExSync.BeamMonitor.State is expected on struct update:

         %ExSync.BeamMonitor.State{
           state
           | reload_set: MapSet.put(reload_set, module),
             unload_set: MapSet.delete(unload_set, module)
         }

     but got type:

         dynamic()

     where "state" was given the type:

         # type: dynamic()
         # from: lib/exsync/beam_monitor.ex:99:52
         state

     when defining the variable "state", you must also pattern match on "%ExSync.BeamMonitor.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:
     │
 102 │     %State{
     │     ~
     │
     └─ lib/exsync/beam_monitor.ex:102:5: ExSync.BeamMonitor.track_module_change/3

     warning: a struct for ExSync.BeamMonitor.State is expected on struct update:

         %ExSync.BeamMonitor.State{
           state
           | reload_set: MapSet.delete(reload_set, module),
             unload_set: MapSet.put(unload_set, module)
         }

     but got type:

         dynamic()

     where "state" was given the type:

         # type: dynamic()
         # from: lib/exsync/beam_monitor.ex:109:52
         state

     when defining the variable "state", you must also pattern match on "%ExSync.BeamMonitor.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:
     │
 112 │     %State{
     │     ~
     │
     └─ lib/exsync/beam_monitor.ex:112:5: ExSync.BeamMonitor.track_module_change/3
 ```
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