Skip to content

Commit b74efbf

Browse files
committed
1547 use strict: duplicate property definitions in obj literals prohibited
1 parent 3fb064f commit b74efbf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/nodes.coffee

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,14 @@ exports.Obj = class Obj extends Base
779779

780780
compileNode: (o) ->
781781
props = @properties
782+
propNames = []
783+
for prop in @properties
784+
prop = prop.variable if prop.isComplex()
785+
if prop?
786+
propName = prop.unwrapAll().value.toString()
787+
if propName in propNames
788+
throw SyntaxError "duplicate data property #{propName} in object literals are not allowed"
789+
propNames.push propName
782790
return (if @front then '({})' else '{}') unless props.length
783791
if @generated
784792
for node in props when node instanceof Value

0 commit comments

Comments
 (0)