mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-12 11:50:54 -06:00
Remove isSemicolon (fix #200)
This commit is contained in:
parent
c1be793a04
commit
61731eefdf
@ -676,11 +676,6 @@ module ts {
|
||||
return token === SyntaxKind.Identifier || (isInStrictMode ? token > SyntaxKind.LastFutureReservedWord : token > SyntaxKind.LastReservedWord);
|
||||
}
|
||||
|
||||
function isSemicolon(): boolean {
|
||||
// True if real or automatic semicolon
|
||||
return token === SyntaxKind.SemicolonToken || token === SyntaxKind.CloseBraceToken || scanner.hasPrecedingLineBreak();
|
||||
}
|
||||
|
||||
function parseExpected(t: SyntaxKind): boolean {
|
||||
if (token === t) {
|
||||
nextToken();
|
||||
@ -2361,7 +2356,7 @@ module ts {
|
||||
var keywordStart = scanner.getTokenPos();
|
||||
var keywordLength = scanner.getTextPos() - keywordStart;
|
||||
parseExpected(kind === SyntaxKind.BreakStatement ? SyntaxKind.BreakKeyword : SyntaxKind.ContinueKeyword);
|
||||
if (!isSemicolon()) node.label = parseIdentifier();
|
||||
if (!canParseSemicolon()) node.label = parseIdentifier();
|
||||
parseSemicolon();
|
||||
finishNode(node);
|
||||
|
||||
@ -2444,7 +2439,7 @@ module ts {
|
||||
var returnTokenLength = scanner.getTextPos() - returnTokenStart;
|
||||
|
||||
parseExpected(SyntaxKind.ReturnKeyword);
|
||||
if (!isSemicolon()) node.expression = parseExpression();
|
||||
if (!canParseSemicolon()) node.expression = parseExpression();
|
||||
parseSemicolon();
|
||||
|
||||
// In an ambient context, we will already give an error for having a statement.
|
||||
@ -2727,7 +2722,7 @@ module ts {
|
||||
}
|
||||
return body;
|
||||
}
|
||||
if (isSemicolon()) {
|
||||
if (canParseSemicolon()) {
|
||||
parseSemicolon();
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
//// [asiAmbientFunctionDeclaration.ts]
|
||||
declare function foo()
|
||||
|
||||
//// [asiAmbientFunctionDeclaration.js]
|
||||
6
tests/baselines/reference/asiBreak.js
Normal file
6
tests/baselines/reference/asiBreak.js
Normal file
@ -0,0 +1,6 @@
|
||||
//// [asiBreak.ts]
|
||||
while (true) break
|
||||
|
||||
//// [asiBreak.js]
|
||||
while (true)
|
||||
break;
|
||||
6
tests/baselines/reference/asiContinue.js
Normal file
6
tests/baselines/reference/asiContinue.js
Normal file
@ -0,0 +1,6 @@
|
||||
//// [asiContinue.ts]
|
||||
while (true) continue
|
||||
|
||||
//// [asiContinue.js]
|
||||
while (true)
|
||||
continue;
|
||||
5
tests/baselines/reference/asiReturn.errors.txt
Normal file
5
tests/baselines/reference/asiReturn.errors.txt
Normal file
@ -0,0 +1,5 @@
|
||||
==== tests/cases/compiler/asiReturn.ts (1 errors) ====
|
||||
// This should be an error for using a return outside a function, but ASI should work properly
|
||||
return
|
||||
~~~~~~
|
||||
!!! A 'return' statement can only be used within a function body.
|
||||
1
tests/cases/compiler/asiAmbientFunctionDeclaration.ts
Normal file
1
tests/cases/compiler/asiAmbientFunctionDeclaration.ts
Normal file
@ -0,0 +1 @@
|
||||
declare function foo()
|
||||
1
tests/cases/compiler/asiBreak.ts
Normal file
1
tests/cases/compiler/asiBreak.ts
Normal file
@ -0,0 +1 @@
|
||||
while (true) break
|
||||
1
tests/cases/compiler/asiContinue.ts
Normal file
1
tests/cases/compiler/asiContinue.ts
Normal file
@ -0,0 +1 @@
|
||||
while (true) continue
|
||||
2
tests/cases/compiler/asiReturn.ts
Normal file
2
tests/cases/compiler/asiReturn.ts
Normal file
@ -0,0 +1,2 @@
|
||||
// This should be an error for using a return outside a function, but ASI should work properly
|
||||
return
|
||||
Loading…
x
Reference in New Issue
Block a user