File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
OneScript.Language/SyntaxAnalysis
Tests/OneScript.Language.Tests Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -659,6 +659,11 @@ private void DefineLabel(Lexem label)
659659
660660 private void BuildStatement ( )
661661 {
662+ if ( ! _isInAsyncMethod && ( _lastExtractedLexem . Token == Token . Async || _lastExtractedLexem . Token == Token . Await ) )
663+ {
664+ _lastExtractedLexem . Token = Token . NotAToken ;
665+ }
666+
662667 if ( _lastExtractedLexem . Token == Token . NotAToken )
663668 {
664669 BuildSimpleStatement ( ) ;
Original file line number Diff line number Diff line change @@ -1262,7 +1262,7 @@ public void TestAwaitMustBeInAsyncOnly()
12621262
12631263 CatchParsingError ( code , errors =>
12641264 {
1265- errors . Single ( ) . Description . Should ( ) . Contain ( "Await ") ;
1265+ errors . Single ( ) . ErrorId . Should ( ) . Be ( "ExpressionSyntax ") ;
12661266 } ) ;
12671267 }
12681268
@@ -1398,6 +1398,27 @@ public void Goto_Can_Appear_In_CodeBlocks()
13981398 validator . NextChildIs ( NodeKind . Goto ) ;
13991399 validator . NextChildIs ( NodeKind . Assignment ) ;
14001400 }
1401+
1402+ [ Fact ]
1403+ public void Async_And_Await_Are_Ordinary_Identifiers_In_NonAsync_Scope ( )
1404+ {
1405+ var code = @"
1406+ Ждать = ""МояПеременная"";
1407+ Асинх = ""МояПеременная2"";
1408+ " ;
1409+
1410+ var validator = ParseBatchAndGetValidator ( code ) ;
1411+
1412+ validator . Is ( NodeKind . CodeBatch ) ;
1413+
1414+ var awaitNode = validator . NextChild ( ) . Is ( NodeKind . Assignment )
1415+ . NextChildIs ( NodeKind . Identifier )
1416+ . ChildItself ( ) . Value . Should ( ) . Be ( "Ждать" ) ;
1417+
1418+ var asyncNode = validator . NextChild ( ) . Is ( NodeKind . Assignment )
1419+ . NextChildIs ( NodeKind . Identifier )
1420+ . ChildItself ( ) . Value . Should ( ) . Be ( "Асинх" ) ;
1421+ }
14011422
14021423 private static void CatchParsingError ( string code )
14031424 {
You can’t perform that action at this time.
0 commit comments