This ensures reusability for functions/variables that may have been outside a block, but end up inside one afterwards. It also ensure the same tree is produced when incremental parsing. i.e. if you have: declare function F() { } And you add a { above it, then we current have an incremental parsing bug. Namely we would see a FunctionDeclaration node and say 'yes, we can reuse that node while parsing the block'. This is currently broken because the normal parse would not have normally accepted such a node (because of the modifiers). This was an example of contextual parsing of the same kind of node. Something which we do not want to do if we want incremental parsing to work properly.
10 lines
378 B
Plaintext
10 lines
378 B
Plaintext
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock2.ts(2,4): error TS1184: Modifiers cannot appear here.
|
|
|
|
|
|
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock2.ts (1 errors) ====
|
|
{
|
|
declare var x = this;
|
|
~~~~~~~
|
|
!!! error TS1184: Modifiers cannot appear here.
|
|
}
|
|
|