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

JavaScript `return` keyword gets removed from local function definition in inline code. #746

Closed
atadi96 opened this Issue Aug 25, 2017 · 0 comments

Comments

Projects
None yet
2 participants
@atadi96
Contributor

atadi96 commented Aug 25, 2017

I have found a bug in local function translation when using JS.Inline.

    [<Inline>]
    let testFunc (x:int) =
        JS.Inline ("
            function wontWork(x) {
                return x*x;
            }
            var willWork = function(x) {
                return x*x;
            };
            return {bad: wontWork($0), good: willWork($0)};
        ", x)

    Console.Log(testFunc 3) //{bad: undefined, good: 9}

In the above code snippet, the return keyword erroneously gets removed from the local function definition, which makes the wontWork function always return undefined. However, using the second syntax, the function definition gets translated correctly, retaining the return keyword, which causes the final output {bad: undefined, good: 9}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment