Uploaded image for project: 'Commons JEXL'
  1. Commons JEXL
  2. JEXL-271

Hoisted variable is lost when currying lambda

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1
    • 3.2
    • None

    Description

      I have noticed that when I curry the lambda that contains hoisted variable, then binding to that variable is lost when I call curried lambda. The following test case illustrates the problem

          @Test
          public void testCurry4() throws Exception {
              JexlEngine jexl = new JexlBuilder().strict(false).create();
              JexlScript base = jexl.createScript("var base = 2; var sum = (x, y, z)->{ base + x + y + z }; var y = sum.curry(1); y(2,3)");
              Object result = base.execute(null);
              Assert.assertEquals(8, result);
          }
      

      To put it another way, the following script returns 2 when it should return 0;

      var base = 2; var sum = (x, y, z)->{ base + x + y + z }; var y = sum.curry(1); sum(1, 2, 3) - y(2,3)

      Attachments

        Activity

          People

            henrib Henri Biestro
            dmitri_blinov Dmitri Blinov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: