legend-pure icon indicating copy to clipboard operation
legend-pure copied to clipboard

Invalid Java generation for function eval with unused result

Open kevin-m-knight-gs opened this issue 1 year ago • 0 comments

Bug Report

Steps to Reproduce:

The following code compiles in Pure, but yields a Java compilation error in compiled mode.

import test::*;

function test::inspect<T|m>(values:T[m], fn:Function<{T[m]->Any[*]}>[1]):T[m]
{
    $fn->eval($values);
    $values;
}

function test::test():Any[*]
{
    inspect([1, 2, 3, 4], v | $v->map(i | $i->toString())->joinStrings('[', ', ', ']\\n'))
}

An ignored failing test was added for this in this commit.

Expected Result:

The Java code that is generated for the Pure code should compile (and behave correctly).

Actual Result:

What actually happens is a Java compilation error which complains that the generated Java code is not a statement.

Environment:

This was reproduced with legend-pure 3.7.0 and JDK 11.0.16.

kevin-m-knight-gs avatar Oct 21 '22 13:10 kevin-m-knight-gs