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

Fix warnings #46

Closed
wants to merge 1 commit into from
Closed

Fix warnings #46

wants to merge 1 commit into from

Conversation

dvic
Copy link

@dvic dvic commented May 27, 2024

Fix warnings as of 1.2.0-rc2 1.2.0

@dvic
Copy link
Author

dvic commented May 27, 2024

There is still one warning left, but this looks like a compiler issue if I'm not mistaken?

❯ gleam build
Downloading packages
 Downloaded 2 packages in 0.02s
  Compiling gleam_stdlib
  Compiling gleeunit
  Compiling gleam_erlang
/Users/dvic/Development/gleam_erlang/build/dev/erlang/gleam_erlang/_gleam_artefacts/gleam@erlang@process_test.erl:442:39: Warning: type variable 'GGA' is only used once (is unbound)
%  442| -spec try_call_timeout_test() -> {ok, GGA} |
%     |                                       ^

   Compiled in 0.78s

@lpil
Copy link
Member

lpil commented May 29, 2024

What version is that on @dvic ?

@dvic
Copy link
Author

dvic commented May 29, 2024

What version is that on @dvic ?

1.2.0

@dvic
Copy link
Author

dvic commented May 29, 2024

I think I see what's going on: if I add Nil as the return value to the test in question then the warning goes away:

pub fn try_call_timeout_test() {
  let parent_subject = process.new_subject()

  process.start(linked: True, running: fn() {
    // Send the call subject to the parent
    let child_subject = process.new_subject()
    process.send(parent_subject, child_subject)
    // Wait for the subject to be called
    let assert Ok(_) = process.receive(child_subject, 50)
    // Never reply
    process.sleep(100)
  })

  let assert Ok(call_subject) = process.receive(parent_subject, 50)

  // Call the child process over the subject
  let assert Error(process.CallTimeout) =
    process.try_call(call_subject, fn(x) { x }, 10)
  Nil
}

So the function is returning
image

hence the warning, it should use term() in the typespec I guess?

@lpil
Copy link
Member

lpil commented May 29, 2024

Thank you. What version of OTP? I'm surprised we're seeing this only now.

@dvic
Copy link
Author

dvic commented May 29, 2024

Thank you. What version of OTP? I'm surprised we're seeing this only now.

26.2.5, I just tried it with 25.3.2.2 and I see no warnings.

@dvic
Copy link
Author

dvic commented May 29, 2024

Looks like this was indeed intentionally fixed on OTP 26 erlang/otp#6915

@lpil
Copy link
Member

lpil commented May 30, 2024

So if I'm reading this right it is now invalid to have a type parameter that is only used right. Does that match your understanding?

@dvic
Copy link
Author

dvic commented May 30, 2024

So if I'm reading this right it is now invalid to have a type parameter that is only used right. Does that match your understanding?

Yes, that’s what I also make of it.

@dvic
Copy link
Author

dvic commented May 30, 2024

Or maybe if ‘when XYZ :: term’ is added, the warning goes away? Not sure

@lpil
Copy link
Member

lpil commented May 30, 2024

OK I think this requires a compiler fix. Could you open an issue in the compiler repo with that link, I think we need to replace single type variables with term().

@dvic
Copy link
Author

dvic commented Jul 13, 2024

@lpil this one got closed by accident because of #3247, that PR only fixed the unbound types issue. This PR also fixed some regular warnings (unnecessary asserts):
image

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.

None yet

2 participants