This argument cannot be applied without label. Confused, can anyone explain?

Hello everyone,

Can someone explain this to me ?

let log_name = (first_name, ~last_name=?) => {
  switch last_name {
  | None => Console.log2(first_name, "Noname")
  | Some(last_name) => Console.log2(first_name, last_name)

let ada = "Ada"

// this is OK

// this is OK too

// this is not OK

Error message is:

  We've found a bug for you!

  32 ┆ ada->log_name(~last_name="Lovelace")
  33 ┆ // this is not
  34 ┆ ada->log_name()
  35 ┆
  36 ┆ Assert.pass(~message="OK")

  The function applied to this argument has type
    ('a, ~last_name: 'b=?) => unit
This argument cannot be applied without label

So to answer my newbie question, it works if we write the call without arguments like this:


I guess otherwise, it means that we pass () (unit) as second argument, hence the failure.


Yes that’s exactly what it means.

1 Like

Working with pipes can be tricky if you aren’t used to it, but once you grok it you will never want to go back.

let fn = str =>
1 Like