Strange code generated for a function (known bug?)

I noticed by using Closure Compiler that a couple of functions from the Colors library generated JS code that contained variable redeclarations.

I tested it further (not on 0.14 though) and got to this small function where the problem still occurs:

f :: Number → Number → Number
f s   0.0 = 1.0
f s'  v'  = s
  where
    s = s' + v'

Generates:

var f = function (v) {
    return function (v1) {
        var s = v;
        if (v1 === 0.0) {
            return 1.0;
        };
        var s = v + v1;
        return s;
    };
};

Renaming the s function to anything else fixes the problem.

I was just wondering if anyone else is aware of this as I couldn’t find an open bug for it.

I think this is benign, right? A variable redeclaration is not semantically different than just omitting the var on the second declaration.

Yes, absolutely. Sorry, I should be clearer on what my concern was.
I thought variable redeclarations weren’t allowed on strict mode, but apparently CC with advanced optimizations on warns about that anyways.
Nothing to see here! :slight_smile: