Ahnfelt / funk

PROTOTYPE: A minimal scripting language - OOP via lambda functions and pattern matching
53 stars 2 forks source link

Delegation raises "Unexpected argument" #1

Closed edcrypt closed 7 years ago

edcrypt commented 7 years ago

Really liked the concept. It's quite close to something that has been bouncing on my head for quite some time (a decade :P)

I think I found an issue that I don't have the time right now to check.

Trying:

:a {
  :b 1
  {
      |Add n| n + b
  }
}

:c a()

system.SetText(c.Add(2))

Results on:

Unexpected argument: function(_X) { if(_X == "Add") { return function(_X) { var n_ = _X; return _A(_A(n_, "+"), b_); }; } throw "Unexpected argument: " + _X;}

While:


:a {
  {
      |Add n| n + 1
  }
}

:c a()

system.SetText(c.Add(2))

Works.

Ahnfelt commented 7 years ago

Thank you for the kind words and the bug report. I appreciate the feedback.

I think it's a problem with the parser, parsing:

:b 1
{
    |Add n| n + b
}

as

:b(1)({
    |Add n| n + b
})

I'll look into it tomorrow.

Thanks again! Best regards Joakim

Ahnfelt commented 7 years ago

The bug turned out to be very simple to fix (one character in parser.js), so it should work now.

Best regards Joakim

edcrypt commented 7 years ago

Thanks @Ahnfelt !

Unfortunately, a similar case remains:

:a {|b|
  {
      |Add n| n + b
  }
}

:c {|b d|
   :aA a(b)
   {
      |m| aA(m)
   }
}
:e c(1, 2)

system.SetText(e.Add(2))

Gives:

Unexpected argument: function (_X) { var m_ = _X; return _A(aA_, m_); }

Regards,

Ahnfelt commented 7 years ago

Right you are!

It turned out that I reenabled significant line breaks after skipping whitespace after ')'. It's fixed now.

Thank you for reporting the problem, it's a big help towards improving the implementation quality.