Parcourir la source

Improved source location for dotted assign expressions

Dmitry Panov il y a 2 ans
Parent
commit
623f9dda90
2 fichiers modifiés avec 12 ajouts et 0 suppressions
  1. 1 0
      compiler_expr.go
  2. 11 0
      compiler_test.go

+ 1 - 0
compiler_expr.go

@@ -971,6 +971,7 @@ func (e *compiledDotExpr) emitRef() {
 func (e *compiledDotExpr) emitSetter(valueExpr compiledExpr, putOnStack bool) {
 	e.left.emitGetter(true)
 	valueExpr.emitGetter(true)
+	e.addSrcMap()
 	if e.c.scope.strict {
 		if putOnStack {
 			e.c.emit(setPropStrict(e.name))

+ 11 - 0
compiler_test.go

@@ -4610,6 +4610,17 @@ func TestSrcLocations(t *testing.T) {
 						["test.js", "", 49, 4]
 						]);
 	}
+
+	try {
+		let n;
+		n.field = {
+	        "key1": "test",
+	        "key2": {},
+		}
+	} catch(e) {
+		assertStack(e, [["test.js", "", 58, 5]
+						]);
+	}
 	`
 	testScriptWithTestLibX(SCRIPT, _undefined, t)
 }