Skip to content

Commit c8bdcfd

Browse files
committed
fixed bug in operator outlining transformation
1 parent e70803b commit c8bdcfd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

build/transformations/operatorOutlining.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,14 @@ var OperatorOutlining = /** @class */ (function (_super) {
153153
if (node.type === 'AssignmentExpression') {
154154
if (node.operator !== '=' && node.left.type === 'Identifier') {
155155
if (Math.random() <= _this.settings.assignmentOperatorChance) {
156+
// @ts-ignore
156157
return {
157158
type: 'AssignmentExpression',
158159
operator: '=',
159160
left: node.left,
160161
right: {
161162
type: 'BinaryExpression',
162-
operator: '+',
163+
operator: node.operator.substring(0, node.operator.length - 1),
163164
left: node.left,
164165
right: node.right
165166
}

src/transformations/operatorOutlining.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,14 @@ class OperatorOutlining extends BaseTransformation {
137137
if (node.type === 'AssignmentExpression') {
138138
if (node.operator !== '=' && node.left.type === 'Identifier') {
139139
if (Math.random() <= this.settings.assignmentOperatorChance) {
140+
// @ts-ignore
140141
return {
141142
type: 'AssignmentExpression',
142143
operator: '=',
143144
left: node.left,
144145
right: {
145146
type: 'BinaryExpression',
146-
operator: '+',
147+
operator: node.operator.substring(0, node.operator.length - 1),
147148
left: node.left,
148149
right: node.right
149150
}

0 commit comments

Comments
 (0)