Skip to content

Commit

Permalink
fix empty file error
Browse files Browse the repository at this point in the history
+ 1.0.10 version bump
  • Loading branch information
michal-kapala committed Mar 28, 2024
1 parent da4bfbe commit 100dada
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jitterbit-script",
"version": "1.0.9",
"version": "1.0.10",
"description": "Static typechecker and interpreter for Jitterbit Script",
"main": "build/index.js",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions src/frontend/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ export default class Parser {
* @throws `ParserError` (runtime-only)
*/
private removeScopeTags(diagnostics?: Diagnostic[]): boolean {
// empty script
if(this.tokens.length === 0) {
if(diagnostics)
return true;
else
throw new ParserError("Empty script.");
}

// find the evaluation scope - <trans>...</trans>
let result = false;
let openIdx: number | null = null;
Expand Down
5 changes: 5 additions & 0 deletions tests/typechecker/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,9 @@ msg = Case(
// Expected expression before the end of script.
expect(result.diagnostics[0].error).toStrictEqual(true);
});

test('Empty file.', function() {
const result = typecheck("");
expect(result.diagnostics.length).toStrictEqual(0);
});
});

0 comments on commit 100dada

Please sign in to comment.