Skip to content

Error when using ... and not _ #8334

@CarlOlson

Description

@CarlOlson

Playground: https://rescript-lang.org/try?version=v12.0.0-beta.12&module=esmodule&code=C4TwDgpgBMBQsQB7AgJwHYEMA2MBcMUAvFAETCnxIoY5SYAmDAEgPasDWBAFMADRQA5JmIA+KAFd0AS2ABKMZJnBiZRi3YdKsbBBXq2nAIyqDm3gID6c+Lv1NDHAEymH5-lAB03m0A

Code:

type t

external t: t = "t"

external addHook: (t, 'a => unit) => unit = "addHook"

// okay
let addHook1 = addHook(t, _)

// error
let addHook2 = addHook(t, ...)

Error:

[E] Line 9, column 4:

This expression's type contains type variables that cannot be generalized:
  ('_weak5 => unit) => unit
  
  This happens when the type system senses there's a mutation/side-effect,
  in combination with a polymorphic value.
  Using or annotating that value usually solves it.

Versions tested: 11.x and 13.0.0-alpha.3

In this example I would expect that both _ and ... behave the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions