rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

Undocumented syntax error when using `type` in function signature

Open Josef-Thorne-A opened this issue 3 months ago • 0 comments

While trying to figure out how the type keyword behaves in function signatures, I ran into a syntax error that provides no error message or line number: I'm using the latest v12 beta.

let rec patternMatching : type inputStream callback. (ev: event<'inputStream, 'callback>) => unit {
  switch ev {
  | Pipe => patternMatching(Data)
  | Data => patternMatching(End)
  | End => ()
  }
}

This crashes with Fatal error: exception Syntaxerr.Error(_). The code is clearly not valid, but it ought to still report an error cleanly.

Interestingly if you just remove the ticks from the type parameters in event the compiler produces an error successfully. I suspect that the syntax sugar for locally abstract types is probably to blame somehow.

Josef-Thorne-A avatar Sep 05 '25 23:09 Josef-Thorne-A