gleam icon indicating copy to clipboard operation
gleam copied to clipboard

Unused import warning on constructor if type alias with the same name exists

Open joshi-monster opened this issue 6 months ago • 1 comments

wibble.gleam

pub type Wibble {
  Wibble(String)
}

wobble.gleam

import gleam/io
import wibble.{Wibble}

type Wibble =
  wibble.Wibble

pub fn main() {
  let wibble = Wibble("hello")
  io.debug(wibble)
}

gleam check

warning: Unused imported item
  ┌─ /home/arkan/Projects/oss/gleam/bug/src/bug.gleam:2:16
  │
2 │ import wibble.{Wibble}
  │                ^^^^^^ This imported constructor is never used

Hint: You can safely remove it.

I use the constructor in main, and type aliases do not produce new constructors, so I believe this is a false positive. Removing the type alias also gets rid of the warning for some reason.

joshi-monster avatar Aug 21 '24 13:08 joshi-monster