mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
issue #2333: removed gratuitous test, refactored
This commit is contained in:
@@ -1184,28 +1184,29 @@
|
||||
if (prop != null) {
|
||||
propName = prop.unwrapAll().value.toString();
|
||||
isDuplicate = function(x) {
|
||||
return propName === x || +propName === +x || (function() {
|
||||
var ep, ex;
|
||||
ex = ep = null;
|
||||
if (!/^[a-z$_]/i.test(x)) {
|
||||
ex = eval(x);
|
||||
if (propName === ex) {
|
||||
return true;
|
||||
}
|
||||
var ep, ex;
|
||||
if (propName === x) {
|
||||
return true;
|
||||
}
|
||||
ex = ep = null;
|
||||
if (!/^[a-z$_]/i.test(x)) {
|
||||
ex = eval(x);
|
||||
if (propName === ex) {
|
||||
return true;
|
||||
}
|
||||
if (!/^[a-z$_]/i.test(propName)) {
|
||||
ep = eval(propName);
|
||||
if (x === ep) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!/^[a-z$_]/i.test(propName)) {
|
||||
ep = eval(propName);
|
||||
if (x === ep) {
|
||||
return true;
|
||||
}
|
||||
if ((ex != null) && (ep != null)) {
|
||||
if (ex === ep) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ((ex != null) && (ep != null)) {
|
||||
if (ex === ep) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})();
|
||||
}
|
||||
return false;
|
||||
};
|
||||
if (any(propNames, isDuplicate)) {
|
||||
throw SyntaxError("multiple object literal properties named \"" + propName + "\"");
|
||||
|
||||
@@ -807,18 +807,17 @@ exports.Obj = class Obj extends Base
|
||||
if prop?
|
||||
propName = prop.unwrapAll().value.toString()
|
||||
isDuplicate = (x) ->
|
||||
propName is x or +propName is +x or
|
||||
do ->
|
||||
ex = ep = null
|
||||
unless /^[a-z$_]/i.test x
|
||||
ex = eval x
|
||||
return true if propName is ex
|
||||
unless /^[a-z$_]/i.test propName
|
||||
ep = eval propName
|
||||
return true if x is ep
|
||||
if ex? and ep?
|
||||
return true if ex is ep
|
||||
false
|
||||
return true if propName is x
|
||||
ex = ep = null
|
||||
unless /^[a-z$_]/i.test x
|
||||
ex = eval x
|
||||
return true if propName is ex
|
||||
unless /^[a-z$_]/i.test propName
|
||||
ep = eval propName
|
||||
return true if x is ep
|
||||
if ex? and ep?
|
||||
return true if ex is ep
|
||||
false
|
||||
if any propNames, isDuplicate
|
||||
throw SyntaxError "multiple object literal properties named \"#{propName}\""
|
||||
propNames.push propName
|
||||
|
||||
Reference in New Issue
Block a user