Skip to content

Commit

Permalink
removing code that restricts duplicate key names and associated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed May 21, 2012
1 parent 6c6c8bd commit 7c29ea4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 71 deletions.
33 changes: 5 additions & 28 deletions lib/coffee-script/nodes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions src/nodes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -801,16 +801,6 @@ exports.Obj = class Obj extends Base

compileNode: (o) ->
props = @properties
propNames = []
normalise = (v) -> if IDENTIFIER.test v then v else "" + do Function "return #{v}"
for prop in @properties
prop = prop.variable if prop.isComplex()
if prop?
propName = prop.unwrapAll().value.toString()
normalisedPropName = normalise propName
if normalisedPropName in propNames
throw SyntaxError "multiple object literal properties named \"#{propName}\""
propNames.push normalisedPropName
return (if @front then '({})' else '{}') unless props.length
if @generated
for node in props when node instanceof Value
Expand Down
33 changes: 0 additions & 33 deletions test/strict.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -55,41 +55,8 @@ test "octal escape sequences prohibited", ->
strictOk "`'\\1'`"
eq "\\" + "1", `"\\1"`


test "duplicate property definitions in object literals are prohibited", ->
strict 'o = {x:1, x:1}'
strict 'x = 1; o = {x, x: 2}'

test "#2333: more duplicate property prohibitions", ->
usingKeys = (a, b) -> "{#{a}:0, #{b}:0}"
strict '{a, "a":0}'
strict usingKeys "a", '"a"'
strict usingKeys "'a'", "a"
strict usingKeys "'a'", '"a"'
strict usingKeys "'a'", "'a'"
strict usingKeys "0", "0x0"
strict usingKeys "0", "'\\x30'"
strict usingKeys ".1", "0.1"
strict usingKeys ".1", "1e-1"
strict usingKeys "100", "1e2"
strict usingKeys "'\\0'", "'\\x00'"
strict usingKeys "'\\t'", "'\\x09'"
strict usingKeys "'\\\\x00'", "'\\\\\\x7800'"
strict usingKeys "'c'", "'\\c'"
strict usingKeys "'\\\\'", "'\\x5c'"
strict usingKeys "'\\\n0'", "0"
strict usingKeys "'\\\n0'", "'\\x00'"
strict usingKeys "'\\'a'", "\"'a\""
strict usingKeys "'\\\\a'", "'\\\\a'"
strictOk usingKeys "a", "b"
strictOk usingKeys "'\"a\"'", "'a'"
strictOk usingKeys "'\"a\"'", '"\'a\'"'
strictOk usingKeys "0", '"0x0"'
strictOk usingKeys "0", '"\\\\x30"'

test "duplicate formal parameters are prohibited", ->
nonce = {}

# a Param can be an Identifier, ThisProperty( @-param ), Array, or Object
# a Param can also be a splat (...) or an assignment (param=value)
# the following function expressions should throw errors
Expand Down

0 comments on commit 7c29ea4

Please sign in to comment.