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

Opaque type field sharing a name with a function can cause indeterministic compiler errors #4096

Open
sbergen opened this issue Dec 19, 2024 · 3 comments
Labels
bug Something isn't working help wanted Contributions encouraged priority:high

Comments

@sbergen
Copy link
Contributor

sbergen commented Dec 19, 2024

Given a main package source file of

import foo
import gleam/io

pub fn main() {
  let foo = foo.make_wibble()
  foo.wobble()
  io.println("edit this line to change state")
}

and a module foo (this has to match name used in the let binding!) with

import gleam/io

pub opaque type Wibble {
  Wibble(wobble: Int)
}

pub fn wobble() {
  io.debug("edit this line to change state")
}

pub fn make_wibble() -> Wibble {
  Wibble(1)
}

Depending on which file has been edited last, the program will either run fine, or report

error: Type mismatch
  ┌─ /home/sbergen/source/repro/src/repro.gleam:6:6
  │
6 │   foo.wobble()
  │      ^^^^^^^

This value is being called as a function but its type is:

    Int

Gleam version: 1.6.3

@sbergen sbergen added the bug Something isn't working label Dec 19, 2024
sbergen added a commit to sbergen/spoke that referenced this issue Dec 19, 2024
Also, fix nondeterministic compilation, see: gleam-lang/gleam#4096
@GearsDatapacks
Copy link
Member

This is probably due to a caching issue. Changing based on last edited file is something I've noticed before with issues related to the module cache

@lpil
Copy link
Member

lpil commented Dec 20, 2024

Does this happen with the nightly version also?

@sbergen
Copy link
Contributor Author

sbergen commented Dec 20, 2024

Does this happen with the nightly version also?

Reproduces in gleam 1.6.2-nightly-20241219 also.

@lpil lpil added help wanted Contributions encouraged priority:high labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Contributions encouraged priority:high
Projects
None yet
Development

No branches or pull requests

3 participants