Skip to content

Remove elixir v1.19 deprecation warnings#96

Merged
jonasschmidt merged 5 commits into
jonasschmidt:masterfrom
san650:remove-elixir-v1.19-warnings
Dec 15, 2025
Merged

Remove elixir v1.19 deprecation warnings#96
jonasschmidt merged 5 commits into
jonasschmidt:masterfrom
san650:remove-elixir-v1.19-warnings

Conversation

@san650
Copy link
Copy Markdown
Contributor

@san650 san650 commented Dec 4, 2025

After

$ mix compile --force
Compiling 40 files (.ex)
Generated ex_json_schema app

Before

$ mix compile --force
warning: setting :preferred_cli_env in your mix.exs "def project" is deprecated, set it inside "def cli" instead:

    def cli do
      [preferred_envs: [coveralls: :test, dialyzer: :test]]
    end

  (mix 1.19.4) lib/mix/cli.ex:187: Mix.CLI.preferred_cli_env/3
  (mix 1.19.4) lib/mix/cli.ex:170: Mix.CLI.maybe_change_env_and_target/2
  (mix 1.19.4) lib/mix/cli.ex:59: Mix.CLI.proceed/2
  /Users/santiago/.asdf/installs/elixir/1.19.4-otp-28/bin/mix:7: (file)
  (elixir 1.19.4) src/elixir_compiler.erl:81: :elixir_compiler.dispatch/4
  (elixir 1.19.4) src/elixir_compiler.erl:56: :elixir_compiler.compile/4

Compiling 2 files (.ex)
    warning: a struct for ExJsonSchema.Schema.Ref is expected on struct update:

        %ExJsonSchema.Schema.Ref{ref | fragment: []}

    but got type:

        dynamic()

    where "ref" was given the type:

        # type: dynamic()
        # from: lib/ex_json_schema/schema/ref.ex:32:23
        ref

    when defining the variable "ref", you must also pattern match on "%ExJsonSchema.Schema.Ref{}".

    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:
    │
 32 │   defp parse_fragment(ref, fragment) when fragment in [nil, ""], do: %__MODULE__{ref | fragment: []}
    │                                                                      ~
    │
    └─ lib/ex_json_schema/schema/ref.ex:32:70: ExJsonSchema.Schema.Ref.parse_fragment/2

    warning: a struct for ExJsonSchema.Schema.Ref is expected on struct update:

        %ExJsonSchema.Schema.Ref{ref | fragment: pointer, fragment_pointer?: true}

    but got type:

        dynamic()

    where "ref" was given the type:

        # type: dynamic()
        # from: lib/ex_json_schema/schema/ref.ex:34:23
        ref

    when defining the variable "ref", you must also pattern match on "%ExJsonSchema.Schema.Ref{}".

    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:
    │
 45 │     %__MODULE__{ref | fragment: pointer, fragment_pointer?: true}
    │     ~
    │
    └─ lib/ex_json_schema/schema/ref.ex:45:5: ExJsonSchema.Schema.Ref.parse_fragment/2

    warning: a struct for ExJsonSchema.Schema.Ref is expected on struct update:

        %ExJsonSchema.Schema.Ref{ref | fragment: [id]}

    but got type:

        dynamic()

    where "ref" was given the type:

        # type: dynamic()
        # from: lib/ex_json_schema/schema/ref.ex:48:23
        ref

    when defining the variable "ref", you must also pattern match on "%ExJsonSchema.Schema.Ref{}".

    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:
    │
 48 │   defp parse_fragment(ref, id), do: %__MODULE__{ref | fragment: [id]}
    │                                     ~
    │
    └─ lib/ex_json_schema/schema/ref.ex:48:37: ExJsonSchema.Schema.Ref.parse_fragment/2

     warning: a struct for ExJsonSchema.Schema.Root is expected on struct update:

         %ExJsonSchema.Schema.Root{root | schema: schema}

     but got type:

         dynamic()

     where "root" was given the type:

         # type: dynamic()
         # from: lib/ex_json_schema/schema.ex:125:20
         {root, schema} = resolve_with_root(root, root_schema, scope)

     when defining the variable "root", you must also pattern match on "%ExJsonSchema.Schema.Root{}".

     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:
     │
 127 │     %Root{root | schema: schema}
     │     ~
     │
     └─ lib/ex_json_schema/schema.ex:127:5: ExJsonSchema.Schema.resolve_root/2

Copy link
Copy Markdown
Owner

@jonasschmidt jonasschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking the time to look into this. My preference would be to fix those warnings by adding type checks through pattern-matches, instead of removing type information. See my comments for some suggestions on how to make the compiler happy.

Comment thread lib/ex_json_schema/schema/ref.ex Outdated
Comment thread lib/ex_json_schema/schema/ref.ex Outdated
Comment thread lib/ex_json_schema/schema/ref.ex Outdated
Comment thread lib/ex_json_schema/schema/ref.ex Outdated
Comment thread lib/ex_json_schema/schema.ex Outdated
Comment thread lib/ex_json_schema/schema.ex Outdated
Comment thread lib/ex_json_schema/schema.ex Outdated
Comment thread .github/workflows/ci.yml Outdated
san650 and others added 3 commits December 11, 2025 22:48
Co-authored-by: Jonas Schmidt <jonas.schmidt@wooga.net>
Co-authored-by: Jonas Schmidt <jonas.schmidt@wooga.net>
Co-authored-by: Jonas Schmidt <jonas.schmidt@wooga.net>
@san650
Copy link
Copy Markdown
Contributor Author

san650 commented Dec 12, 2025

Thanks for the suggestions @jonasschmidt. I've applied your suggestions and I think the PR is ready to go 💪

@jonasschmidt jonasschmidt merged commit 5f2cc0e into jonasschmidt:master Dec 15, 2025
0 of 3 checks passed
@jonasschmidt
Copy link
Copy Markdown
Owner

Nice, thank you. There were some unrelated build failures that I fixed in master. I'm merging and pushing a new release tomorrow.

@san650 san650 deleted the remove-elixir-v1.19-warnings branch December 15, 2025 18:27
@jonasschmidt
Copy link
Copy Markdown
Owner

Ok, found an unrelated issue caused by OTP 28 switching to a different regex engine, which was failing some tests in the official JSON Schema test suite. That's fixed now as well, and the shiny new version 0.11.2 with your fixes is on hex.pm now: https://hex.pm/packages/ex_json_schema/0.11.2

@san650
Copy link
Copy Markdown
Contributor Author

san650 commented Dec 16, 2025

Thanks @jonasschmidt

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.

2 participants