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

Unnecessary Cloning Operations #23

Open
DavePearce opened this issue Oct 3, 2017 · 0 comments
Open

Unnecessary Cloning Operations #23

DavePearce opened this issue Oct 3, 2017 · 0 comments

Comments

@DavePearce
Copy link
Member

The following generates a clone unexpectedly:

function f(null|int x) -> (int r):
    if x is int:
        return x
    else:
        return 0

This generates the following JavaScript:

function f_u2NI(/*(null|int)*/ x)// -> (/*int*/ r)
{
    // function or method body
    if(typeof x === "number") {
            return Wy.copy(x);
        } else {
            return 0;
        }
}

Obviously, it's strange that we have Wy.copy(x) here. I'm guessing the reason for this is that isCopyable() doesn't think about union types properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant