Skip to content

[@bs] at application side treats f () as 0-arity application #674

@andreypopp

Description

@andreypopp

Consider this gist:

let sleep ms =
  Js.Promise.make @@ fun ~resolve ~reject:_ ->
  ignore (Js.Global.setInterval (fun () -> (resolve () [@bs])) ms)

which errors with

Line 3, 44: Error This expression has type ('a -> unit)   
  Js__Js_internal.Fn.arity1 but an expression was expected of type 'b  
  Js__Js_internal.Fn.arity0

The issue is that Melange treats f ()[@bs] syntax as 0-arity application.
If we do

let unit = () in f unit [@bs]

then it compiles.

I think 0-arity applications should have another syntax.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions