Skip to content

Default values for function args breaks currying #983

@johnhaley81

Description

@johnhaley81

I'm trying to call a function being passed to me in a Js.t({..}) and it's not being called as I expected.

ReasonML Code:

"onNavigate": (query, event) => props##applyFilter(. query, event),

Function in JS Code side:

applyFilter: (query, event = {}) => {
  // snip
};

I think what is happening is the second arg event is being assigned a default value so when this function is called with a currying style that arg is not set properly.

So now another interesting thing is, when I call the function in a uncurried way:

"onNavigate": (query, event) => props##applyFilter(. query, event),

I get the following warning:

Alert unused: Unused attribute [@u]

Which I believe is a false positive because in this situation the function is now called correctly!

So it seems that there are 2 main issues:

  1. Default values for function args breaks the currying system (at least when the functions are a property of a JS object)
  2. When calling a function uncurried, if that function is in a Js.t({..}) you'll get a warning about an unused attribute [@u] (playground link)

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