mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 05:30:13 +03:00
Improve parser errors for statements at global scope (#20871)
This commit is contained in:
parent
e85bc5f16e
commit
4b57724c91
9 changed files with 75 additions and 19 deletions
26
compiler/test/fail_compilation/code_global_scope.d
Normal file
26
compiler/test/fail_compilation/code_global_scope.d
Normal file
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/code_global_scope.d(18): Error: `switch` statement must be inside function scope
|
||||
fail_compilation/code_global_scope.d(19): Error: `do` statement must be inside function scope
|
||||
fail_compilation/code_global_scope.d(20): Error: `foreach` statement must be inside function scope
|
||||
fail_compilation/code_global_scope.d(21): Error: `while` statement must be inside function scope
|
||||
fail_compilation/code_global_scope.d(22): Error: `if` statement must be inside function scope
|
||||
fail_compilation/code_global_scope.d(23): Error: `return` statement must be inside function scope
|
||||
fail_compilation/code_global_scope.d(24): Error: `goto` statement must be inside function scope
|
||||
fail_compilation/code_global_scope.d(25): Error: `continue` statement must be inside function scope
|
||||
fail_compilation/code_global_scope.d(26): Error: `break` statement must be inside function scope
|
||||
---
|
||||
*/
|
||||
|
||||
|
||||
|
||||
switch s;
|
||||
do d;
|
||||
foreach (i; 0 .. 4) {}
|
||||
while (x) {}
|
||||
if (y) {}
|
||||
return 0;
|
||||
goto A;
|
||||
continue B;
|
||||
break;
|
Loading…
Add table
Add a link
Reference in a new issue