Skip to content

Commit

Permalink
fix: goldstein: keyword: broken-string: infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Jun 3, 2024
1 parent 8124d2f commit 775a6fc
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/goldstein/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ test('goldstein: parse: if let', (t) => {
const expected = montag`
{
let a = b?.c;
if (a) {
log(a);
}
Expand Down
1 change: 1 addition & 0 deletions packages/keyword-broken-string/fixture/infinite.gs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const a = 'b
1 change: 1 addition & 0 deletions packages/keyword-broken-string/fixture/infinite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const a = '';
3 changes: 3 additions & 0 deletions packages/keyword-broken-string/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export default function keywordBrokenString(Parser) {
for (;;) {
const ch = this.input.charCodeAt(this.pos);

if (!ch)
break;

if (ch === quote)
break;

Expand Down
5 changes: 5 additions & 0 deletions packages/keyword-broken-string/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ test('goldstein: broken-string: no-semi', (t) => {
t.compile('no-semi');
t.end();
});

test('goldstein: broken-string: infinite', (t) => {
t.compile('infinite');
t.end();
});
1 change: 1 addition & 0 deletions packages/keyword-if/fixture/if-let.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let a = 5;
{
let x = john.info?.name;

if (x) {
print(x);
}
Expand Down

0 comments on commit 775a6fc

Please sign in to comment.