mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Fix speculative parsing by terminating the list when encounting illegal token
This commit is contained in:
parent
57e1cf984a
commit
e9beba783e
@ -2440,6 +2440,14 @@ module ts {
|
||||
// a generator, or in strict mode (or both)) and it started a yield expression.
|
||||
return true;
|
||||
default:
|
||||
// Error tolerance. If we see the start of some binary operator, we consider
|
||||
// that the start of an expression. That way we'll parse out a missing identifier,
|
||||
// give a good message about an identifier being missing, and then consume the
|
||||
// rest of the binary expression.
|
||||
if (isBinaryOperator()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isIdentifier();
|
||||
}
|
||||
}
|
||||
@ -2826,7 +2834,7 @@ module ts {
|
||||
// reScanGreaterToken so that we merge token sequences like > and = into >=
|
||||
|
||||
reScanGreaterToken();
|
||||
var newPrecedence = getOperatorPrecedence();
|
||||
var newPrecedence = getBinaryOperatorPrecedence();
|
||||
|
||||
// Check the precedence to see if we should "take" this operator
|
||||
if (newPrecedence <= precedence) {
|
||||
@ -2845,7 +2853,15 @@ module ts {
|
||||
return leftOperand;
|
||||
}
|
||||
|
||||
function getOperatorPrecedence(): number {
|
||||
function isBinaryOperator() {
|
||||
if (inDisallowInContext() && token === SyntaxKind.InKeyword) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return getBinaryOperatorPrecedence() > 0;
|
||||
}
|
||||
|
||||
function getBinaryOperatorPrecedence(): number {
|
||||
switch (token) {
|
||||
case SyntaxKind.BarBarToken:
|
||||
return 1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user