diff --git a/package.json b/package.json
index 1341001..824312d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "jitterbit-script",
- "version": "1.0.10",
+ "version": "1.0.11",
"description": "Static typechecker and interpreter for Jitterbit Script",
"main": "build/index.js",
"scripts": {
diff --git a/src/frontend/parser.ts b/src/frontend/parser.ts
index 220f1ec..91fa702 100644
--- a/src/frontend/parser.ts
+++ b/src/frontend/parser.ts
@@ -214,13 +214,17 @@ export default class Parser {
}
}
// Remove and , restore EOF
- this.tokens.shift();
- const last = this.tokens.pop() as Token;
- if(last.type === TokenType.CloseTransTag) {
- this.endTagStart = last.begin;
- this.endTagEnd = last.end;
+ if(diagnostics && this.tokens.length < 2)
+ return result;
+ else {
+ this.tokens.shift();
+ const last = this.tokens.pop() as Token;
+ if(last.type === TokenType.CloseTransTag) {
+ this.endTagStart = last.begin;
+ this.endTagEnd = last.end;
+ }
+ this.tokens.push(new Token("EndOfFile", TokenType.EOF, last.end, last.end));
}
- this.tokens.push(new Token("EndOfFile", TokenType.EOF, last.end, last.end));
return result;
}
diff --git a/test.jb b/test.jb
index b26601c..33e12d9 100644
--- a/test.jb
+++ b/test.jb
@@ -1,3 +1 @@
-
- x +
-
\ No newline at end of file
+<><
\ No newline at end of file
diff --git a/tests/typechecker/errors.test.ts b/tests/typechecker/errors.test.ts
index 5f5eb91..a353e71 100644
--- a/tests/typechecker/errors.test.ts
+++ b/tests/typechecker/errors.test.ts
@@ -275,4 +275,22 @@ msg = Case(
const result = typecheck("");
expect(result.diagnostics.length).toStrictEqual(0);
});
+
+ test('"<" script.', function() {
+ const result = typecheck("<");
+ expect(result.diagnostics.length).toStrictEqual(2);
+ // No tag, the script returns its content as string.
+ expect(result.diagnostics[0].error).toStrictEqual(true);
+ // The script is missing '' scope closing tag.
+ expect(result.diagnostics[1].error).toStrictEqual(true);
+ });
+
+ test('Fish script ("<><").', function() {
+ const result = typecheck("<");
+ expect(result.diagnostics.length).toStrictEqual(2);
+ // No tag, the script returns its content as string.
+ expect(result.diagnostics[0].error).toStrictEqual(true);
+ // The script is missing '' scope closing tag.
+ expect(result.diagnostics[1].error).toStrictEqual(true);
+ });
});