Combination of - and _ params causes JSC_DUPLICATE_PARAM

Description

The following function definitions each cause ERROR: JSC_DUPLICATE_PARAM. Parse error. Duplicate parameter name "_" at compile time with :advanced compilation:

1 2 3 4 5 6 7 8 9 10 11 (defn causes-duplicate-param [{_ :foo}] (reify Object (a-function [-] (fn [] "arbitrary function inside a-function body")))) (defn causes-duplicate-param [{- :foo}] (reify Object (a-function [_] (fn [] "arbitrary function inside a-function body"))))

They generate, respectively:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 duplicate_param_name_demo.core.t_duplicate_param_name_demo$core1601.prototype.a_function = ((function (map__1599,map__1599__$1,_){ return (function (){ var self__ = this; var _ = this; return ((function (_,map__1599,map__1599__$1,_){ return (function (){ return "arbitrary function inside a-function body"; }); ;})(_,map__1599,map__1599__$1,_)) });})(map__1599,map__1599__$1,_)) ; duplicate_param_name_demo.core.t_duplicate_param_name_demo$core1612.prototype.a_function = ((function (map__1610,map__1610__$1,_){ return (function (){ var self__ = this; var _ = this; return ((function (_,map__1610,map__1610__$1,_){ return (function (){ return "arbitrary function inside a-function body"; }); ;})(_,map__1610,map__1610__$1,_)) });})(map__1610,map__1610__$1,_)) ;

(Notice the duplicate _ param on the 5th line of each.)

The following do not:

1 2 3 4 5 6 7 8 9 10 11 (defn causes-duplicate-param [{- :foo}] (reify Object (a-function [-] (fn [] "arbitrary function inside a-function body")))) (defn causes-duplicate-param [{_ :foo}] (reify Object (a-function [_] (fn [] "arbitrary function inside a-function body"))))

They generate:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 duplicate_param_name_demo.core.t_duplicate_param_name_demo$core1601.prototype.a_function = ((function (map__1599,map__1599__$1,_){ return (function (){ var self__ = this; var ___$1 = this; return ((function (___$1,map__1599,map__1599__$1,_){ return (function (){ return "arbitrary function inside a-function body"; }); ;})(___$1,map__1599,map__1599__$1,_)) });})(map__1599,map__1599__$1,_)) ; duplicate_param_name_demo.core.t_duplicate_param_name_demo$core1612.prototype.a_function = ((function (map__1610,map__1610__$1,_){ return (function (){ var self__ = this; var ___$1 = this; return ((function (___$1,map__1610,map__1610__$1,_){ return (function (){ return "arbitrary function inside a-function body"; }); ;})(___$1,map__1610,map__1610__$1,_)) });})(map__1610,map__1610__$1,_)) ;

(Notice that one of the _ params has become ___$1.)

My guess, though I haven't looked into the compiler code, is that the compiler escapes _ to ___$1 when it would conflict with another _, and also it translates - to _, but it doesn't notice the conflict when the ClojureScript symbols are different.

Environment

None

Status

Assignee

Unassigned

Reporter

import

Labels

None

Approval

None

Patch

None

Priority

Minor
Configure