Skip to content

Commit 7605e98

Browse files
Matthew Tebbsriknoll
Matthew Tebbs
authored andcommitted
Fix double newline emit for property change/set statements. (microsoft#4180)
1 parent 50e3855 commit 7605e98

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

cli/pyconv.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@ function stmt(e: py.Stmt): B.JsNode {
18481848
currErrs = ""
18491849
}
18501850
if (cmts.length) {
1851-
r = B.mkGroup(cmts.map(c => B.H.mkComment(c)).concat(r))
1851+
r = B.mkGroup(cmts.map(c => B.mkStmt(B.H.mkComment(c))).concat(r))
18521852
}
18531853
return r
18541854
}

pxtblocks/blocklycompiler.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1108,13 +1108,9 @@ namespace pxt.blocks {
11081108
} else if (func.f == "@get@") {
11091109
return H.mkPropertyAccess(args[1].op.replace(/.*\./, ""), args[0]);
11101110
} else if (func.f == "@set@") {
1111-
return H.mkAssign(
1112-
H.mkPropertyAccess(args[1].op.replace(/.*\./, "").replace(/@set/, ""), args[0]),
1113-
args[2]);
1111+
return H.mkAssign(H.mkPropertyAccess(args[1].op.replace(/.*\./, "").replace(/@set/, ""), args[0]), args[2]);
11141112
} else if (func.f == "@change@") {
1115-
return mkStmt(H.mkSimpleCall("+=", [
1116-
H.mkPropertyAccess(args[1].op.replace(/.*\./, "").replace(/@set/, ""), args[0]),
1117-
args[2]]))
1113+
return H.mkSimpleCall("+=", [H.mkPropertyAccess(args[1].op.replace(/.*\./, "").replace(/@set/, ""), args[0]), args[2]])
11181114
} else if (func.isExtensionMethod) {
11191115
if (func.attrs.defaultInstance) {
11201116
let instance: JsNode;

pxtlib/jsoutput.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ namespace pxt.blocks {
180180
}
181181

182182
export function mkComment(text: string) {
183-
return mkStmt(mkText("// " + text))
183+
return mkText("// " + text)
184184
}
185185

186186
export function mkMultiComment(text: string) {
@@ -206,7 +206,7 @@ namespace pxt.blocks {
206206
}
207207

208208
export function mkAssign(x: JsNode, e: JsNode): JsNode {
209-
return mkStmt(mkSimpleCall("=", [x, e]))
209+
return mkSimpleCall("=", [x, e])
210210
}
211211

212212
export function mkParenthesizedExpression(expression: JsNode): JsNode {

0 commit comments

Comments
 (0)