Skip to content

Commit dfeed9b

Browse files
authored
fix(statements): Use prefixed strings to avoid internal conflicts (#29)
1 parent ec6269b commit dfeed9b

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

src/nodes/BlockStatement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default class BlockStatement extends BaseJSNode<ESTree.BlockStatement> {
99
if (stmt.type === 'ReturnStatement')
1010
return result;
1111

12-
if (result === 'break' || result === 'continue')
12+
if (result === '$jintr_break_' || result === '$jintr_continue_')
1313
return result;
1414

1515
if (

src/nodes/BreakStatement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import BaseJSNode from './BaseJSNode.js';
44
export default class BreakStatement extends BaseJSNode<ESTree.BreakStatement> {
55
public run(): any {
66
// @TODO: Parse label
7-
return 'break';
7+
return '$jintr_break_';
88
}
99
}

src/nodes/ContinueStatement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import BaseJSNode from './BaseJSNode.js';
33

44
export default class ContinueStatement extends BaseJSNode<ESTree.ContinueStatement> {
55
public run(): any {
6-
return 'continue';
6+
return '$jintr_continue_';
77
}
88
}

src/nodes/ForOfStatement.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ export default class ForOfStatement extends BaseJSNode<ESTree.ForOfStatement> {
2020

2121
const body = this.visitor.visitNode(this.node.body);
2222

23-
if (body === 'break') {
23+
if (body === '$jintr_break_') {
2424
break;
2525
}
2626

27-
if (body === 'continue') {
27+
if (body === '$jintr_continue_') {
2828
continue;
2929
}
3030

src/nodes/ForStatement.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ export default class ForStatement extends BaseJSNode<ESTree.ForStatement> {
2222

2323
const body = this.visitor.visitNode(this.node.body);
2424

25-
if (body === 'continue') {
25+
if (body === '$jintr_continue_') {
2626
continue;
2727
}
2828

29-
if (body === 'break') {
29+
if (body === '$jintr_break_') {
3030
break;
3131
}
3232

src/nodes/SwitchStatement.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ export default class SwitchStatement extends BaseJSNode<ESTree.SwitchStatement>
1616
const result = this.visitor.visitNode(_case);
1717

1818
// If it's a break then stop here.
19-
if (result === 'break') {
19+
if (result === '$jintr_break_') {
2020
break;
2121
}
2222

2323
// Switch statements do not support continue, but it can be used when inside a while/for loop.
24-
if (result === 'continue') {
24+
if (result === '$jintr_continue_') {
2525
return result;
2626
}
2727

src/nodes/WhileStatement.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ export default class WhileStatement extends BaseJSNode<ESTree.WhileStatement> {
66
while (this.visitor.visitNode(this.node.test)) {
77
const body = this.visitor.visitNode(this.node.body);
88

9-
if (body === 'break')
9+
if (body === '$jintr_break_')
1010
break;
1111

12-
if (body === 'continue')
12+
if (body === '$jintr_continue_')
1313
continue;
1414

1515
if (body)

0 commit comments

Comments
 (0)