diff --git a/.gitignore b/.gitignore index 98a3ba835b..3166d113d2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ raw/ .idea cli/index.generated.js src/diagnosticMessages.generated.ts +coverage/ diff --git a/tests/parser/arrow-functions.ts b/tests/parser/arrow-functions.ts index 8c842f65c2..6ef3e37592 100644 --- a/tests/parser/arrow-functions.ts +++ b/tests/parser/arrow-functions.ts @@ -9,3 +9,7 @@ x => x; // not an array function (b ? x : y); (b ? f : g)(); + +(b ? x | y); +// ERROR 1005: "')' expected." +(x: i32 => x; diff --git a/tests/parser/arrow-functions.ts.fixture.ts b/tests/parser/arrow-functions.ts.fixture.ts index 3f049b2a6a..00cd257092 100644 --- a/tests/parser/arrow-functions.ts.fixture.ts +++ b/tests/parser/arrow-functions.ts.fixture.ts @@ -6,3 +6,4 @@ x => x; (b ? x : y); (b ? f : g)(); +// ERROR 1005: "':' expected." in arrow-functions.ts(13,10+1) diff --git a/tests/parser/call-function-return.ts b/tests/parser/call-function-return.ts index c83e13788b..5172fa3783 100644 --- a/tests/parser/call-function-return.ts +++ b/tests/parser/call-function-return.ts @@ -1 +1,5 @@ a = fn()(1, 2); +// ERROR 1042: "'declare' modifier cannot be used here." +declare b = fn()(1, 2); +// ERROR 1005: "')' expected." +a = fn()(1, 2; diff --git a/tests/parser/call-function-return.ts.fixture.ts b/tests/parser/call-function-return.ts.fixture.ts index c83e13788b..3130ccd669 100644 --- a/tests/parser/call-function-return.ts.fixture.ts +++ b/tests/parser/call-function-return.ts.fixture.ts @@ -1 +1,5 @@ a = fn()(1, 2); +b = fn()(1, 2); +a = fn(); +// ERROR 1042: "'declare' modifier cannot be used here." in call-function-return.ts(3,1+7) +// ERROR 1005: "')' expected." in call-function-return.ts(5,13+1) diff --git a/tests/parser/calls.ts b/tests/parser/calls.ts index 2e9b0d9374..76b58aecf7 100644 --- a/tests/parser/calls.ts +++ b/tests/parser/calls.ts @@ -14,3 +14,5 @@ obj.a(1); // Everything id(a)[0](b)(c).a(d)(e)[1](f)(g); +// ERROR 1003: "Identifier expected." +obj.(b ? f : g)(); diff --git a/tests/parser/calls.ts.fixture.ts b/tests/parser/calls.ts.fixture.ts index 81e0e3d2c9..f366b910d4 100644 --- a/tests/parser/calls.ts.fixture.ts +++ b/tests/parser/calls.ts.fixture.ts @@ -5,3 +5,4 @@ arr[0](1); obj.a(); obj.a(1); id(a)[0](b)(c).a(d)(e)[1](f)(g); +// ERROR 1003: "Identifier expected." in calls.ts(18,5+13) diff --git a/tests/parser/class-expression.ts b/tests/parser/class-expression.ts index 2c1824ab5f..41a8b932b5 100644 --- a/tests/parser/class-expression.ts +++ b/tests/parser/class-expression.ts @@ -3,3 +3,9 @@ var a = class { bar: i32; }; var b = class Foo {}; +// ERROR 1005: "'{' expected." +var c = class [bar: i32]; +// ERROR 1003: "Identifier expected." +// ERROR 1005: "'}' expected." +var d = class bat { + diff --git a/tests/parser/class-expression.ts.fixture.ts b/tests/parser/class-expression.ts.fixture.ts index 2c1824ab5f..11d359bb5d 100644 --- a/tests/parser/class-expression.ts.fixture.ts +++ b/tests/parser/class-expression.ts.fixture.ts @@ -3,3 +3,6 @@ var a = class { bar: i32; }; var b = class Foo {}; +// ERROR 1005: "'{' expected." in class-expression.ts(7,14+0) +// ERROR 1003: "Identifier expected." in class-expression.ts(10,19+1) +// ERROR 1005: "'}' expected." in class-expression.ts(11,3+1) diff --git a/tests/parser/class.ts b/tests/parser/class.ts index b55a2880e6..648250b2be 100644 --- a/tests/parser/class.ts +++ b/tests/parser/class.ts @@ -37,4 +37,26 @@ export class Invalid { // 1031: 'declare' modifier cannot appear on class elements of this kind. // 1183: An implementation cannot be declared in ambient contexts. declare declareMethod(): i32 {} + + // ERROR 1042: "'readonly' modifier cannot be used here." + readonly get name():i32 {} + // ERROR 1049: "A 'set' accessor must have exactly one parameter." + // ERROR 1042: "'readonly' modifier cannot be used here." + // ERROR 1095: "A 'set' accessor cannot have a return type annotation." + readonly set name():i32 {} + + // ERROR 1042: "'static' modifier cannot be used here." + static constructor(a: i32) {} + + // ERROR 1042: "'abstract' modifier cannot be used here." + abstract constructor(a: i32) {} + + // ERROR 1042: "'readonly' modifier cannot be used here." + readonly constructor(a: i32) {} } + + +export abstract class Invalid { + // ERROR 1245: "Method 'constructor' cannot have an implementation because it is marked abstract." + abstract constructor(a: i32) {} +} \ No newline at end of file diff --git a/tests/parser/class.ts.fixture.ts b/tests/parser/class.ts.fixture.ts index 9d25f7a31d..b1fe154834 100644 --- a/tests/parser/class.ts.fixture.ts +++ b/tests/parser/class.ts.fixture.ts @@ -17,6 +17,14 @@ export class Invalid { declare declareField: i32; declare declareInitializer: i32 = 0; declare declareMethod(): i32 {} + readonly get name(): i32 {} + readonly set name() {} + static constructor(a: i32) {} + constructor(a: i32) {} + readonly constructor(a: i32) {} +} +export abstract class Invalid { + abstract constructor(a: i32) {} } // ERROR 1092: "Type parameters cannot appear on a constructor declaration." in class.ts(15,14+3) // ERROR 1110: "Type expected." in class.ts(18,21+0) @@ -31,3 +39,12 @@ export class Invalid { // ERROR 1039: "Initializers are not allowed in ambient contexts." in class.ts(35,35+1) // ERROR 1031: "'declare' modifier cannot appear on class elements of this kind." in class.ts(39,3+7) // ERROR 1183: "An implementation cannot be declared in ambient contexts." in class.ts(39,32+1) +// ERROR 1042: "'readonly' modifier cannot be used here." in class.ts(42,3+8) +// ERROR 1042: "'readonly' modifier cannot be used here." in class.ts(46,3+8) +// ERROR 1049: "A 'set' accessor must have exactly one parameter." in class.ts(46,16+4) +// ERROR 1095: "A 'set' accessor cannot have a return type annotation." in class.ts(46,22+1) +// ERROR 1042: "'static' modifier cannot be used here." in class.ts(49,3+6) +// ERROR 1042: "'abstract' modifier cannot be used here." in class.ts(52,3+8) +// ERROR 1042: "'readonly' modifier cannot be used here." in class.ts(55,3+8) +// ERROR 1042: "'abstract' modifier cannot be used here." in class.ts(61,3+8) +// ERROR 1245: "Method 'constructor' cannot have an implementation because it is marked abstract." in class.ts(61,32+1) diff --git a/tests/parser/constructor.ts b/tests/parser/constructor.ts index 454260eae2..ccc3b6346d 100644 --- a/tests/parser/constructor.ts +++ b/tests/parser/constructor.ts @@ -2,6 +2,9 @@ class MyClass { constructor() {} constructor(a: i32) {} constructor(a: i32, b: i32) {} + constructor(a: i32, b: i32, protected c:f32) {} + //ERROR 1317: "A parameter property cannot be declared using a rest parameter." + constructor(a: i32, b: i32, protected c:f32, protected ...d:i32[]) {} } class MyClassImplicit { diff --git a/tests/parser/constructor.ts.fixture.ts b/tests/parser/constructor.ts.fixture.ts index 481863215c..752763afa8 100644 --- a/tests/parser/constructor.ts.fixture.ts +++ b/tests/parser/constructor.ts.fixture.ts @@ -2,7 +2,10 @@ class MyClass { constructor() {} constructor(a: i32) {} constructor(a: i32, b: i32) {} + constructor(a: i32, b: i32, protected c: f32) {} + constructor(a: i32, b: i32, protected c: f32, protected ...d: Array) {} } class MyClassImplicit { constructor(public a: i32, private readonly b: i32 = 2, c: i32 = 3) {} } +// ERROR 1317: "A parameter property cannot be declared using a rest parameter." in constructor.ts(7,58+3) diff --git a/tests/parser/decorators.ts b/tests/parser/decorators.ts index 5cb19ded08..5e40465eb7 100644 --- a/tests/parser/decorators.ts +++ b/tests/parser/decorators.ts @@ -9,3 +9,4 @@ @external("a", "b") @custom function a(): void {} +@operator. // ERROR 1126: "Unexpected end of text." diff --git a/tests/parser/decorators.ts.fixture.ts b/tests/parser/decorators.ts.fixture.ts index 5cb19ded08..e9aac1b9df 100644 --- a/tests/parser/decorators.ts.fixture.ts +++ b/tests/parser/decorators.ts.fixture.ts @@ -9,3 +9,5 @@ @external("a", "b") @custom function a(): void {} +// ERROR 1003: "Identifier expected." in decorators.ts(12,10+1) +// ERROR 1126: "Unexpected end of text." in decorators.ts(12,12+0) diff --git a/tests/parser/do.ts b/tests/parser/do.ts index b5c27f3459..130b4aa27b 100644 --- a/tests/parser/do.ts +++ b/tests/parser/do.ts @@ -3,3 +3,5 @@ do { } while (a != b); do b; while (a); +// ERROR 1005: "'(' expected." +do{} while; diff --git a/tests/parser/do.ts.fixture.ts b/tests/parser/do.ts.fixture.ts index b5c27f3459..7e3a3d6f60 100644 --- a/tests/parser/do.ts.fixture.ts +++ b/tests/parser/do.ts.fixture.ts @@ -3,3 +3,4 @@ do { } while (a != b); do b; while (a); +// ERROR 1005: "'(' expected." in do.ts(7,6+5) diff --git a/tests/parser/export-default.ts b/tests/parser/export-default.ts index 5c00aae7af..c102a1586c 100644 --- a/tests/parser/export-default.ts +++ b/tests/parser/export-default.ts @@ -4,3 +4,11 @@ export default class TheClass {} export default enum TheEnum {} export default namespace theNamespace {} export default something; +// ERROR 1109: "Expression expected." +export import A = B? ; + +export import A = :B? ; +// ERROR 1005: "'=' expected." +export import A (= B)? ; +// ERROR 1003: "Identifier expected." +export import: A (= B)? ; diff --git a/tests/parser/export-default.ts.fixture.ts b/tests/parser/export-default.ts.fixture.ts index d2832910ba..30d391353a 100644 --- a/tests/parser/export-default.ts.fixture.ts +++ b/tests/parser/export-default.ts.fixture.ts @@ -5,3 +5,7 @@ export default namespace theNamespace {} export { something as default }; +export import A = B; +// ERROR 1109: "Expression expected." in export-default.ts(8,20+1) +// ERROR 1005: "'=' expected." in export-default.ts(12,15+1) +// ERROR 1003: "Identifier expected." in export-default.ts(14,8+6) diff --git a/tests/parser/for.ts b/tests/parser/for.ts index 3e10da956f..2f48855b57 100644 --- a/tests/parser/for.ts +++ b/tests/parser/for.ts @@ -7,3 +7,7 @@ for (i = 0; i < 10; ++i) { for (;;) { ; } +// ERROR 1155: "'const' declarations must be initialized." +for (const i; i < 10; i++) { + +} diff --git a/tests/parser/for.ts.fixture.ts b/tests/parser/for.ts.fixture.ts index 3e10da956f..8b4aea03fb 100644 --- a/tests/parser/for.ts.fixture.ts +++ b/tests/parser/for.ts.fixture.ts @@ -7,3 +7,5 @@ for (i = 0; i < 10; ++i) { for (;;) { ; } +for (const i; i < 10; i++) {} +// ERROR 1155: "'const' declarations must be initialized." in for.ts(11,12+1) diff --git a/tests/parser/forof.ts b/tests/parser/forof.ts index 3cab01d38c..512797a190 100644 --- a/tests/parser/forof.ts +++ b/tests/parser/forof.ts @@ -14,3 +14,5 @@ for (foo of bar) ; for (var foo of bar) ; for (let foo of bar) ; for (const foo of bar) ; +// ERROR 1155: "'const' declarations must be initialized." +for (const foo from bar) ; diff --git a/tests/parser/forof.ts.fixture.ts b/tests/parser/forof.ts.fixture.ts index 3cab01d38c..b2be725c62 100644 --- a/tests/parser/forof.ts.fixture.ts +++ b/tests/parser/forof.ts.fixture.ts @@ -14,3 +14,5 @@ for (foo of bar) ; for (var foo of bar) ; for (let foo of bar) ; for (const foo of bar) ; +// ERROR 1155: "'const' declarations must be initialized." in forof.ts(18,12+3) +// ERROR 1005: "';' expected." in forof.ts(18,12+3) diff --git a/tests/parser/function-expression.ts b/tests/parser/function-expression.ts index bbd37e9918..1ac322098f 100644 --- a/tests/parser/function-expression.ts +++ b/tests/parser/function-expression.ts @@ -14,3 +14,7 @@ var e = (a: i32, b: i32): i32 => { ; }; var f = (a: i32): i32 => a; +// ERROR 1005: "'(' expected." +var g = function:void{ + ; +}; diff --git a/tests/parser/function-expression.ts.fixture.ts b/tests/parser/function-expression.ts.fixture.ts index bbd37e9918..cf3b1b60b5 100644 --- a/tests/parser/function-expression.ts.fixture.ts +++ b/tests/parser/function-expression.ts.fixture.ts @@ -14,3 +14,4 @@ var e = (a: i32, b: i32): i32 => { ; }; var f = (a: i32): i32 => a; +// ERROR 1005: "'(' expected." in function-expression.ts(18,17+0) diff --git a/tests/parser/function.ts b/tests/parser/function.ts index c1e254db36..bd8473c7ea 100644 --- a/tests/parser/function.ts +++ b/tests/parser/function.ts @@ -4,3 +4,103 @@ function typeparams(a: V | null = null): void {} function withdecorator(): void {} function withthis(this: i32): i32 { return this; } function withthisp(this: i32, a: f32, b: f64): i32 { return this; } + +// 1003: Identifier expected. +function typevoid void>():void{} + +// 1003: Identifier expected. +function extendsfunctiontype(this: ()=>void):void {} + +// 1005: ':' expected. +function extendsinsteadofcolon(this extends i32):void {} + +// 1003: Identifier expected. +function typeNone():void{} + +// 1005: ')' expected. +function functionforgetcomma(this: ()=>void a: i32):void {} + +function trycatchFunction(): void { + try { + } + catch (exception_var) { + } + finally { + } +} +// ERROR 1003: "Identifier expected." +function deeperFunction():void{{++a;}} +// ERROR 1003: "Identifier expected." +function identifierFunction():void{var a = 0;} +// ERROR 1003: "Identifier expected." +function stringFunction():void{"string"} +// ERROR 1005: "'(' expected." +function backtick Function():void{`${a}bc`} +// ERROR 1003: "Identifier expected." +// ERROR 1351: "An identifier or keyword cannot immediately follow a numeric literal." +function deeperFunction():void{1.23f} + +function errorTrycatchFunction(): void { + // ERROR 1005: "'(' expected." + try { + } + catch { + } + finally { + } + // ERROR 1003: "Identifier expected." + try { + } + catch (var) { + } + finally { + } + // ERROR 1005: "'{' expected." + try { + } + catch (exception_var) + finally { + } + // ERROR 1005: "'(' expected." + try { + } catch + // ERROR 1005: "'{' expected." + try { + } + catch (exception_var) {} + finally() + // ERROR 1005: "'{' expected." + try(a()) + // ERROR 1005: "'catch' expected." + try{a()} +} + +function switchError(i: i32): void{ + + switch(i) { + case constant-expression1: { + break; + } + default: { + break; + } + } + // ERROR 1005: "'(' expected." + switch {i} { + + } + // ERROR 1005: "'{' expected." + switch (i) [] + +} + +function ifError(i: i32): void{ + // ERROR 1005: "'(' expected." + if {i} + +} + +function doError(i: i32): void{ + // ERROR 1005: "'while' expected." + do {} +} \ No newline at end of file diff --git a/tests/parser/function.ts.fixture.ts b/tests/parser/function.ts.fixture.ts index be705e4334..f8519d78a6 100644 --- a/tests/parser/function.ts.fixture.ts +++ b/tests/parser/function.ts.fixture.ts @@ -8,3 +8,58 @@ function withthis(this: i32): i32 { function withthisp(this: i32, a: f32, b: f64): i32 { return this; } +function extendsfunctiontype(): void {} +function trycatchFunction(): void { + try { + } catch (exception_var) { + } finally { + } + } +function errorTrycatchFunction(): void {} +function switchError(i: i32): void { + switch (i) { + case constant - expression1: + { + break; + } + + default: + { + break; + } + +} + } +function ifError(i: i32): void {} +function doError(i: i32): void {} +// ERROR 1003: "Identifier expected." in function.ts(9,29+10) +// ERROR 1003: "Identifier expected." in function.ts(12,36+8) +// ERROR 1005: "':' expected." in function.ts(15,32+4) +// ERROR 1003: "Identifier expected." in function.ts(18,19+4) +// ERROR 1003: "Identifier expected." in function.ts(21,36+8) +// ERROR 1005: "')' expected." in function.ts(21,40+4) +// ERROR 1003: "Identifier expected." in function.ts(32,25+4) +// ERROR 1003: "Identifier expected." in function.ts(34,29+4) +// ERROR 1003: "Identifier expected." in function.ts(36,25+4) +// ERROR 1005: "'(' expected." in function.ts(38,18+0) +// ERROR 1003: "Identifier expected." in function.ts(41,25+4) +// ERROR 1351: "An identifier or keyword cannot immediately follow a numeric literal." in function.ts(41,42+0) +// ERROR 1005: "'(' expected." in function.ts(47,3+5) +// ERROR 1109: "Expression expected." in function.ts(47,3+5) +// ERROR 1109: "Expression expected." in function.ts(49,3+7) +// ERROR 1003: "Identifier expected." in function.ts(54,9+1) +// ERROR 1109: "Expression expected." in function.ts(54,3+5) +// ERROR 1109: "Expression expected." in function.ts(56,3+7) +// ERROR 1005: "'{' expected." in function.ts(61,23+1) +// ERROR 1109: "Expression expected." in function.ts(61,3+5) +// ERROR 1109: "Expression expected." in function.ts(62,3+7) +// ERROR 1005: "'(' expected." in function.ts(66,5+5) +// ERROR 1005: "'{' expected." in function.ts(71,3+7) +// ERROR 1109: "Expression expected." in function.ts(70,3+5) +// ERROR 1109: "Expression expected." in function.ts(71,3+7) +// ERROR 1005: "'{' expected." in function.ts(73,3+3) +// ERROR 1005: "'catch' expected." in function.ts(75,10+1) +// ERROR 1005: "'(' expected." in function.ts(89,3+6) +// ERROR 1005: "'{' expected." in function.ts(93,12+1) +// ERROR 1005: "'(' expected." in function.ts(99,3+2) +// ERROR 1005: "'while' expected." in function.ts(105,7+1) diff --git a/tests/parser/import.ts b/tests/parser/import.ts index f78be31a7c..27bd788071 100644 --- a/tests/parser/import.ts +++ b/tests/parser/import.ts @@ -14,3 +14,17 @@ import { } from "./other"; import * as A from "./other"; import "./other"; +// ERROR 1005: "'}' expected." +import {A from "./other"; +// ERROR 1003: "Identifier expected." +import * as =A from "./other"; +// ERROR 1005: "'as' expected." +import * A from "./other"; + +import A from "./other" +// ERROR 100: "Not implemented: Mixed default and named imports" +import A, B from "./other" + +import {A} from B; + +import {A} by "./other"; diff --git a/tests/parser/import.ts.fixture.ts b/tests/parser/import.ts.fixture.ts index f78be31a7c..065454d9f7 100644 --- a/tests/parser/import.ts.fixture.ts +++ b/tests/parser/import.ts.fixture.ts @@ -14,3 +14,12 @@ import { } from "./other"; import * as A from "./other"; import "./other"; +import { + default as A +} from "./other"; +// ERROR 1005: "'}' expected." in import.ts(18,9+1) +// ERROR 1003: "Identifier expected." in import.ts(20,10+2) +// ERROR 1005: "'as' expected." in import.ts(22,8+1) +// ERROR 100: "Not implemented: Mixed default and named imports" in import.ts(26,9+1) +// ERROR 1141: "String literal expected." in import.ts(28,12+4) +// ERROR 1005: "'from' expected." in import.ts(30,10+1) diff --git a/tests/parser/index-declaration.ts b/tests/parser/index-declaration.ts index e9374e8e20..9bf864aac0 100644 --- a/tests/parser/index-declaration.ts +++ b/tests/parser/index-declaration.ts @@ -1,3 +1,64 @@ class A { [key: i32]: f64; } +// ERROR 1206: "Decorators are not valid here." +class B { + @final [key: i32]: f64; +} +// ERROR 1005: "':' expected." +class C { + [key extends i32]: f64; +} +// ERROR 1110: "Type expected." +class D { + [key: ()=>void]: f64; +} +// ERROR 1110: "Type expected." +class E { + [key: ()=>void: f64; +} +// ERROR 1003: "Identifier expected." +class F { + [key: i32]: ()=>void; +} +// ERROR 1005: "':' expected." +class G { + [key: i32]| f64; +} +// ERROR 1005: "'key' expected." +class H { + [keys: i32]: f64; +} +// ERROR 1003: "Identifier expected." +class I { + [()=>string: i32]: f64; +} + +// ERROR 1042: "'public' modifier cannot be used here." +class J { + public [()=>string: i32]: f64; +} +// ERROR 1042: "'protected' modifier cannot be used here." +class K { + protected [()=>string: i32]: f64; +} +// ERROR 1042: "'private' modifier cannot be used here." +class L { + private [()=>string: i32]: f64; +} +// ERROR 1042: "'static' modifier cannot be used here." +class M { + static [()=>string: i32]: f64; +} +// ERROR 1042: "'abstract' modifier cannot be used here." +class N { + abstract [()=>string: i32]: f64; +} +// ERROR 1042: "'readonly' modifier cannot be used here." +class O { + readonly [()=>string: i32]: f64; +} +// ERROR 1005: "']' expected." +class P { + [key: i32 : f64; +} diff --git a/tests/parser/index-declaration.ts.fixture.ts b/tests/parser/index-declaration.ts.fixture.ts index e9374e8e20..9d6abd11a7 100644 --- a/tests/parser/index-declaration.ts.fixture.ts +++ b/tests/parser/index-declaration.ts.fixture.ts @@ -1,3 +1,41 @@ class A { [key: i32]: f64; } +class B { + [key: i32]: f64; +} +class C {} +class D {} +class E {} +class F {} +class G {} +class H {} +class I {} +class J {} +class K {} +class L {} +class M {} +class N {} +class O {} +class P {} +// ERROR 1206: "Decorators are not valid here." in index-declaration.ts(6,3+6) +// ERROR 1005: "':' expected." in index-declaration.ts(10,4+3) +// ERROR 1110: "Type expected." in index-declaration.ts(14,13+4) +// ERROR 1110: "Type expected." in index-declaration.ts(18,13+4) +// ERROR 1003: "Identifier expected." in index-declaration.ts(22,15+8) +// ERROR 1005: "':' expected." in index-declaration.ts(26,12+1) +// ERROR 1005: "'key' expected." in index-declaration.ts(30,4+4) +// ERROR 1003: "Identifier expected." in index-declaration.ts(34,3+1) +// ERROR 1042: "'public' modifier cannot be used here." in index-declaration.ts(39,3+6) +// ERROR 1003: "Identifier expected." in index-declaration.ts(39,10+1) +// ERROR 1042: "'protected' modifier cannot be used here." in index-declaration.ts(43,3+9) +// ERROR 1003: "Identifier expected." in index-declaration.ts(43,13+1) +// ERROR 1042: "'protected' modifier cannot be used here." in index-declaration.ts(47,3+7) +// ERROR 1003: "Identifier expected." in index-declaration.ts(47,11+1) +// ERROR 1042: "'static' modifier cannot be used here." in index-declaration.ts(51,3+6) +// ERROR 1003: "Identifier expected." in index-declaration.ts(51,10+1) +// ERROR 1042: "'abstract' modifier cannot be used here." in index-declaration.ts(55,3+8) +// ERROR 1003: "Identifier expected." in index-declaration.ts(55,12+1) +// ERROR 1003: "Identifier expected." in index-declaration.ts(59,12+1) +// ERROR 1042: "'readonly' modifier cannot be used here." in index-declaration.ts(59,3+8) +// ERROR 1005: "']' expected." in index-declaration.ts(63,9+3) diff --git a/tests/parser/interface.ts b/tests/parser/interface.ts index db94e6119e..e1bdd33801 100644 --- a/tests/parser/interface.ts +++ b/tests/parser/interface.ts @@ -9,3 +9,9 @@ interface Boo { baz: i32, readonly baz2: f64, } + +interface Invalid { + // ERROR 1206: "Decorators are not valid here." + @final baz: i32; + declare baz2: f64; +} diff --git a/tests/parser/interface.ts.fixture.ts b/tests/parser/interface.ts.fixture.ts index aacb138d03..f6b846daac 100644 --- a/tests/parser/interface.ts.fixture.ts +++ b/tests/parser/interface.ts.fixture.ts @@ -8,3 +8,10 @@ interface Boo { baz: i32; readonly baz2: f64; } +interface Invalid { + @final + baz: i32; + baz2: f64; +} +// ERROR 1206: "Decorators are not valid here." in interface.ts(15,3+6) +// ERROR 1042: "'declare' modifier cannot be used here." in interface.ts(16,3+7) diff --git a/tests/parser/literals.ts b/tests/parser/literals.ts index 1f445aeb77..6067eabaf7 100644 --- a/tests/parser/literals.ts +++ b/tests/parser/literals.ts @@ -98,3 +98,5 @@ tag`\unicode\xGG\u\x`; // see https://tc39.es/proposal-template-literal-revision 5 c; 6.7 d; a b; +// ERROR 1005: "'}' expected." +`a${b`; diff --git a/tests/parser/literals.ts.fixture.ts b/tests/parser/literals.ts.fixture.ts index 8f7d004851..290ca6b93e 100644 --- a/tests/parser/literals.ts.fixture.ts +++ b/tests/parser/literals.ts.fixture.ts @@ -107,3 +107,5 @@ b; // ERROR 1125: "Hexadecimal digit expected." in literals.ts(94,4+1) // ERROR 1125: "Hexadecimal digit expected." in literals.ts(94,12+1) // ERROR 1125: "Hexadecimal digit expected." in literals.ts(94,16+1) +// ERROR 1002: "Unterminated string literal." in literals.ts(102,6+3) +// ERROR 1005: "'}' expected." in literals.ts(102,6+3) diff --git a/tests/parser/module.ts b/tests/parser/module.ts index c22817d3ea..a9c7d6fc22 100644 --- a/tests/parser/module.ts +++ b/tests/parser/module.ts @@ -1,2 +1,10 @@ module "abc"; declare module "abc"; + + +declare module `a \ +bc`; + +//ERROR 1038: "A 'declare' modifier cannot be used in an already ambient context." +declare namespace A {declare module "abc"}; + diff --git a/tests/parser/module.ts.fixture.ts b/tests/parser/module.ts.fixture.ts index c22817d3ea..9d5dccc86d 100644 --- a/tests/parser/module.ts.fixture.ts +++ b/tests/parser/module.ts.fixture.ts @@ -1,2 +1,7 @@ module "abc"; declare module "abc"; +module`a bc`; +declare namespace A { + module "abc"; +} +// ERROR 1038: "A 'declare' modifier cannot be used in an already ambient context." in module.ts(9,22+7) diff --git a/tests/parser/optional-typeparameters.ts b/tests/parser/optional-typeparameters.ts index fd9ac6dc72..72b1fd698b 100644 --- a/tests/parser/optional-typeparameters.ts +++ b/tests/parser/optional-typeparameters.ts @@ -1,3 +1,4 @@ function a(): T { return 0; } function a(): T { return 0; } function a(): T { return 0; } // ERROR 2706 +function b void>(): T { return 0; } // ERROR 1003 \ No newline at end of file diff --git a/tests/parser/optional-typeparameters.ts.fixture.ts b/tests/parser/optional-typeparameters.ts.fixture.ts index 05cf48a0d0..eac5797f75 100644 --- a/tests/parser/optional-typeparameters.ts.fixture.ts +++ b/tests/parser/optional-typeparameters.ts.fixture.ts @@ -8,3 +8,4 @@ function a(): T { return 0; } // ERROR 2706: "Required type parameters may not follow optional type parameters." in optional-typeparameters.ts(3,20+1) +// ERROR 1003: "Identifier expected." in optional-typeparameters.ts(4,16+10) diff --git a/tests/parser/string-binding.ts b/tests/parser/string-binding.ts index 876de12874..feef9d4e62 100644 --- a/tests/parser/string-binding.ts +++ b/tests/parser/string-binding.ts @@ -48,4 +48,7 @@ export class ExternalString { @binding(BindingCall.THIS, [ BindingType.OBJECT_HANDLE ], BindingType.PASS_THRU) @operator("==") equals(other: String): bool { return unreachable(); } + // ERROR 1005: "']' expected." + @binding(BindingCall.THIS, [, BindingType.OBJECT_HANDLE) + trimStartError(): String { return unreachable(); } } diff --git a/tests/parser/string-binding.ts.fixture.ts b/tests/parser/string-binding.ts.fixture.ts index 373498726c..9b9075a050 100644 --- a/tests/parser/string-binding.ts.fixture.ts +++ b/tests/parser/string-binding.ts.fixture.ts @@ -62,4 +62,9 @@ export class ExternalString { equals(other: String): bool { return unreachable(); } + trimStartError(): String { + return unreachable(); + } } +// ERROR 1005: "']' expected." in string-binding.ts(52,45+13) +// ERROR 1003: "Identifier expected." in string-binding.ts(52,45+13) diff --git a/tests/parser/type-signature.ts b/tests/parser/type-signature.ts index 1e28ea4bf5..0274b1050c 100644 --- a/tests/parser/type-signature.ts +++ b/tests/parser/type-signature.ts @@ -6,3 +6,17 @@ type foo = (this: AClass, a: i32) => i32; type foo = () => () => void; type foo = () => (() => void) | null; type foo = (this: AClass, a: i32) => ((this: BClass, b?: f32) => i32) | null; +// ERROR 1005: "')' expected." +type foo = (() => void | null; +// ERROR 1005: "'|' expected." +type foo = (() => void); +//ERROR 1005: "'null' expected." +type foo = () | void; + +type bar = (foo); +// ERROR 1005: "')' expected." +type bar = (foo; +type bar = (true); +type bar = (this); +type bar = (null); +type bar = ("a"); diff --git a/tests/parser/type-signature.ts.fixture.ts b/tests/parser/type-signature.ts.fixture.ts index 1e28ea4bf5..57f3f5a776 100644 --- a/tests/parser/type-signature.ts.fixture.ts +++ b/tests/parser/type-signature.ts.fixture.ts @@ -6,3 +6,13 @@ type foo = (this: AClass, a: i32) => i32; type foo = () => () => void; type foo = () => (() => void) | null; type foo = (this: AClass, a: i32) => ((this: BClass, b?: f32) => i32) | null; +type bar = foo; +type bar = bool; +type bar = this; +type bar = null; +type bar = string; +// ERROR 1005: "')' expected." in type-signature.ts(10,26+4) +// ERROR 1005: "'|' expected." in type-signature.ts(12,23+1) +// ERROR 1005: "'=>' expected." in type-signature.ts(14,13+1) +// ERROR 1012: "Unexpected token." in type-signature.ts(14,13+1) +// ERROR 1005: "')' expected." in type-signature.ts(18,16+0)