Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing violation in elixir 1.18.0-rc.0 #669

Closed
ashkhn opened this issue Dec 16, 2024 · 2 comments · Fixed by #670
Closed

Typing violation in elixir 1.18.0-rc.0 #669

ashkhn opened this issue Dec 16, 2024 · 2 comments · Fixed by #670

Comments

@ashkhn
Copy link

ashkhn commented Dec 16, 2024

Compiling a rustler project using the latest elixir 1.18-rc.0
generates the following compile warning at the use Rustler injection site

    warning: the following clause will never match:

        {^default_load_data_value, {module, function}}

    because it attempts to match on the result of:

        {0, nil}

    which has type:

        {integer(), nil}

    where "default_load_data_value" (context Rustler) was given the type:

        # type: integer()
        # from: lib/rustler_mix_test.ex:1
        default_load_data_value = 0

    typing violation found at:
    │
  1 │ defmodule RustlerMixTest do
    │ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    │
    └─ lib/rustler_mix_test.ex:1: RustlerMixTest._construct_load_data/0

The warning originates at this pattern match
presumably because the compiler infers the types of load_data and load_data_fun based on the default values set in struct definition? 🤔

I'm not sure if it's a false positive in the 1.18 compiler so I opened an issue here first for confirmation 🙇

@filmor
Copy link
Member

filmor commented Dec 17, 2024

I looked a bit into this. I think the issue is that we generate a macro within __before_compile__ which then uses case expressions in its body where the values to match are completely static. I'll rewrite this section to "run" the case directly in __before_compile__ instead.

@filmor
Copy link
Member

filmor commented Dec 17, 2024

I'll see to it that a new version of rustler is released around the 1.18 final release. Maybe we can get some other smaller changes in before.

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 a pull request may close this issue.

2 participants