Skip to content

Conversation

@woylie
Copy link
Contributor

@woylie woylie commented Jan 6, 2026

Fixes this warning:

    warning: a struct for Ecto.Changeset is expected on struct update:

        %Ecto.Changeset{
          changeset
          | action: parent_action,
            params: params,
            errors: errors,
            valid?: errors == []
        }

    but got type:

        dynamic()

    where "changeset" was given the type:

        # type: dynamic()
        # from: lib/polymorphic_embed/html/helpers.ex:76:19
        changeset =
          apply_action(
            Ecto.Changeset.change(data),
            parent_action
          )

    when defining the variable "changeset", you must also pattern match on "%Ecto.Changeset{}".

    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:
    │
 83 │         changeset = %Ecto.Changeset{
    │                     ~
    │
    └─ lib/polymorphic_embed/html/helpers.ex:83:21: PolymorphicEmbed.HTML.Helpers.to_form/4

@coveralls
Copy link

coveralls commented Jan 6, 2026

Pull Request Test Coverage Report for Build ebe5ef0a22737e3b000ea256383255c9591cfa49-PR-140

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 82.933%

Totals Coverage Status
Change from base Build 17b5c7687076b7b199108b76e0de4a6b5e337959: 0.0%
Covered Lines: 311
Relevant Lines: 375

💛 - Coveralls

@mathieuprog mathieuprog merged commit 4ecac6a into mathieuprog:master Jan 6, 2026
9 checks passed
@mathieuprog
Copy link
Owner

Released in 5.0.6

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.

3 participants