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

False Positive When Using First Class Module Type Alias #1050

Open
LTibbetts opened this issue Aug 1, 2023 · 0 comments
Open

False Positive When Using First Class Module Type Alias #1050

LTibbetts opened this issue Aug 1, 2023 · 0 comments

Comments

@LTibbetts
Copy link

I ran across a case where false positives were being generated for first class modules. In particular the false positive was only generated if a type alias was used for the module's type. I have recreated a minimal reproduction of the issue below. I have already taken one attempt at fixing this myself but it introduced more false positives in our codebase. Any help or pointers would be appreciated!

Example First Class Module

module type ModuleType = {
  type t
}

module MakeWithType = (A: ModuleType): (ModuleType with type t = A.t) => {
  type t = A.t
}

let main = () => {
  let moduleA: module(ModuleType with type t = int) = module(
    MakeWithType({
      type t = int
    })
  )

  let module(A) = moduleA

  let intA: A.t = 1

  Js.log(intA)
}

main()

Example First Class Module with False Positive

module type ModuleType = {
  type t
}

module MakeWithType = (A: ModuleType): (ModuleType with type t = A.t) => {
  type t = A.t
}

type moduleAlias<'a> = module(ModuleType with type t = 'a)

let main = () => {
  // Marked as dead (transitively) due to type alias
  let moduleA: moduleAlias<int> = module(
    MakeWithType({
      type t = int
    })
  )
 
  // Marked as dead (false positive)
  let module(A) = moduleA

  // Live usage of module A
  let intA: A.t = 1

  Js.log(intA)
}

main()
@fhammerschmidt fhammerschmidt transferred this issue from rescript-lang/reanalyze Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants