Compile() throws error for a function of the product of variables

Aug 2 at 6:23 AM
Edited Aug 2 at 6:27 AM

First of all: what a great piece of work this library is. I am very impressed by the elegance and its usefulness.

Here is an issue I stumbled upon. If I try to compile a function that is a simple product of two variables, the compiler throws an error in the function GenerateCode()(System.Collections.Generic.KeyNotFoundException).

This also happens in Optimizers.Sample3(), where g1 is the product of 4 variables:
Function g1 = x1 * x2 * x3 * x4;
The error occurs when I uncomment the compile section (was it commented because it gave an error?):
CompiledFunction[] c = Compiler.Compile(new Function[] { f, g1, g2 }, new Variable[] { x1, x2, x3, x4 }, 2);
It also doesn't work with the simplest example of two variables:
            Variable x = new Variable();
            Variable y = new Variable();

            Function f0 = x * y;
            f0 = Compiler.Compile(f, new Variable[] { x, y }, 2);
=> error thrown

Interestingly enough it DOES work when I add a dummy Function to the equation:
            Function f0 = Function.Abs(1) * x * y;
            f0 = Compiler.Compile(f0, new Variable[] { x, y }, 2);
Which is good enough for a workaround I guess.

I hope this is useful information for the author or anyone who comes across the same thing.