issue #2333: removed gratuitous test, refactored

This commit is contained in:
Michael Ficarra
2012-05-16 02:07:35 -04:00
parent dc9565f54a
commit 55e1386503
2 changed files with 31 additions and 31 deletions

View File

@@ -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 + "\"");

View File

@@ -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