Skip to content

Using a lambda function inside an if statement does not work #15

@Feliix42

Description

@Feliix42

When trying to compile the following snippet

ns some_ns;

use sf calculations (generate_value, generate_data, calculate, check_if_to_run);

fn main() -> i32 {
    let x = generate_value();
    let y = generate_data();
    let z = check_if_to_run();

    let f = fn(d) { calculate(d, x) };

    if (z) {
        f(y)
    } else {
        y
    }
}

ohuac (v0.2.0) yields the following error:

ohuac: FatalError {fatalErrorMessage = "Undefined Binding: DFVar Binding \"y_0\"
defined vars: fromList [(Binding \"__2\",Target {operator = FnId 7, index = 1}),
(Binding \"z_0\",Target {operator = FnId 2, index = -1}),
(Binding \"a\",Target {operator = FnId 5, index = -1}),
(Binding \"x_0\",Target {operator = FnId 1, index = -1}),
(Binding \"b\",Target {operator = FnId 10, index = -1}),
(Binding \"x_0_0\",Target {operator = FnId 8, index = 0}),
(Binding \"c\",Target {operator = FnId 6, index = -1}),
(Binding \"d_0\",Target {operator = FnId 4, index = -1}),
(Binding \"y_0_0\",Target {operator = FnId 9, index = 0}),
(Binding \"__1\",Target {operator = FnId 7, index = 0})]"}

When writing y instead of f(y), the algorithm compiles.

I guess this is a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions