Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local mutual tail recursive optimization #737

Closed
Jand42 opened this issue Aug 11, 2017 · 1 comment
Closed

Local mutual tail recursive optimization #737

Jand42 opened this issue Aug 11, 2017 · 1 comment

Comments

@Jand42
Copy link
Member

Jand42 commented Aug 11, 2017

In translated code for local mutually tail-recursive functions, switch case is incorrectly falling over instead of terminating with a break and continuing the while loop.

Failing example:

let tailRecursionOptimizerBug() =
    let rec f x =
        if x = 0 then g x 1 else f (x - 1)
    and g x y =
        x + y
    f 5

Should return 1 but returns NaN.

@Jand42 Jand42 closed this as completed in a16fb05 Aug 11, 2017
@Jand42
Copy link
Member Author

Jand42 commented Aug 14, 2017

Another bug: arguments are not copied when in mutual tail-recursive calls a later argument needs the current value.

Failing example:

let mutualLetRecArgCopying() =
    let rec f x y z =
        if x = 0 then 
            if y = 0 then g z else y + z
        else f (x - 1) y z
    and g x = 
        f 0 1 x
    f 5 0 5

g loops to f with states 0, 1, 0 in translated code because the value of x is not copied before being overwritten.

@Jand42 Jand42 reopened this Aug 14, 2017
Jand42 added a commit that referenced this issue Aug 14, 2017
@Jand42 Jand42 closed this as completed Aug 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant