Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Differentiate between fn(.) and fn(.()) #138

Closed
ryyppy opened this issue Sep 15, 2020 · 0 comments · Fixed by #139
Closed

Differentiate between fn(.) and fn(.()) #138

ryyppy opened this issue Sep 15, 2020 · 0 comments · Fixed by #139

Comments

@ryyppy
Copy link
Member

ryyppy commented Sep 15, 2020

Extracted from this issue:

Currently they are all de-sugared into OCaml syntax fn () [@bs]

The thing is that in BuckleScript, since there is no syntax space for arity zero, so we make a special form that fn () [@bs] is treated arity zero application.

I wonder Reason could make a difference here which feels more intuitive:

fn (.) --> arity zero -> fn () [@bs]
fn (. ()) --> arity 1 -> let unit = () in fn unit of course, some care need to be taken to avoid name collision

Example where this causes an issue:

Js.Promise.make((~resolve, ~reject as _) => Js.Global.setTimeout(() => {
      resolve(. ())
}, 1500)->ignore)

See Playground Link

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant