Skip to content

Commit 2162ea8

Browse files
committed
Merge branch 'master' into enhance/880_typescript-types
2 parents 2c0d7c5 + 97b9d15 commit 2162ea8

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

package-lock.json

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"@types/eslint__js": "8.42.3",
4040
"@types/node": "22.10.2",
4141
"@types/seedrandom": "3.0.8",
42-
"@types/uuid": "10.0.0",
4342
"@vitest/coverage-v8": "2.1.8",
4443
"chalk": "5.4.1",
4544
"eslint": "9.17.0",

playground/package-lock.json

Lines changed: 8 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/parser/scanner.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,10 +621,13 @@ export class Scanner implements ITokenStream<NormalToken> {
621621
private skipCommentRange(): void {
622622
while (true) {
623623
if (this.stream.eof()) {
624-
break;
624+
throw new AiScriptUnexpectedEOFError(this.stream.getPos());
625625
}
626626
if (this.stream.char() === '*') {
627627
this.stream.next();
628+
if (this.stream.eof()) {
629+
throw new AiScriptUnexpectedEOFError(this.stream.getPos());
630+
}
628631
if ((this.stream.char()) === '/') {
629632
this.stream.next();
630633
break;

test/syntax.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as assert from 'assert';
22
import { describe, test } from 'vitest';
33
import { utils } from '../src';
44
import { NUM, STR, NULL, ARR, OBJ, BOOL, TRUE, FALSE, ERROR ,FN_NATIVE } from '../src/interpreter/value';
5-
import { AiScriptRuntimeError } from '../src/error';
5+
import { AiScriptRuntimeError, AiScriptUnexpectedEOFError } from '../src/error';
66
import { exe, getMeta, eq } from './testutils';
77

88
/*
@@ -514,6 +514,16 @@ describe('Comment', () => {
514514
`);
515515
eq(res, STR('a'));
516516
});
517+
518+
test.concurrent('invalid EOF in multi line comment', async () => {
519+
await assert.rejects(() => exe(`
520+
/* comment
521+
`), AiScriptUnexpectedEOFError);
522+
});
523+
524+
test.concurrent('invalid EOF in multi line comment 2', async () => {
525+
await assert.rejects(() => exe('/* comment *'), AiScriptUnexpectedEOFError);
526+
});
517527
});
518528

519529
describe('lang version', () => {

0 commit comments

Comments
 (0)