d796bf1e0a
We now no longer fail a speculative parse just because an error was encountered at any point while speculating. instead, we allow the speculative function that is being called to determine if the parse was successful or not. Only if it decides it was not successful is parsing rewound. This improves our error recovery in several cases (esp. around arrow functions). it will also help in a followup refactoring to prevent lookahead/speculative parsing from causing lambda allocations.
50 lines
1.5 KiB
Plaintext
50 lines
1.5 KiB
Plaintext
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(27,16): error TS1005: ',' expected.
|
|
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(32,23): error TS1005: '(' expected.
|
|
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(37,9): error TS2350: Only a void function can be called with the 'new' keyword.
|
|
|
|
|
|
==== tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts (3 errors) ====
|
|
|
|
class C0 {
|
|
|
|
}
|
|
class C1 {
|
|
constructor(n: number, s: string) { }
|
|
}
|
|
|
|
class T<T> {
|
|
constructor(n?: T) { }
|
|
}
|
|
|
|
var anyCtor: {
|
|
new (): any;
|
|
};
|
|
|
|
var anyCtor1: {
|
|
new (n): any;
|
|
};
|
|
|
|
interface nestedCtor {
|
|
new (): nestedCtor;
|
|
}
|
|
var nestedCtor: nestedCtor;
|
|
|
|
// Construct expression with no parentheses for construct signature with > 0 parameters
|
|
var b = new C0 32, ''; // Parse error
|
|
~~
|
|
!!! error TS1005: ',' expected.
|
|
|
|
// Generic construct expression with no parentheses
|
|
var c1 = new T;
|
|
var c1: T<{}>;
|
|
var c2 = new T<string>; // Parse error
|
|
~
|
|
!!! error TS1005: '(' expected.
|
|
|
|
|
|
// Construct expression of non-void returning function
|
|
function fnNumber(): number { return 32; }
|
|
var s = new fnNumber(); // Error
|
|
~~~~~~~~~~~~~~
|
|
!!! error TS2350: Only a void function can be called with the 'new' keyword.
|
|
|