Skip to content

if as a statement breaks return values in functions #5

@sylvrs

Description

@sylvrs

Overview

The following snippet below should produce the value 3 but instead produces the value 1

// Recursively calculates the fibonacci sequence
fn fibonacci(n: number) {
    @dump_stack();
    if (n <= 1) {
        return n;
    }
    return fibonacci(n - 1) + fibonacci(n - 2);
}

@println(fibonacci(4));

I suspect this is a result of how we handle return values relative to our frame pointer but more investigation is needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions