add `!symbol.is_global()` condition check before entrying global symbol
errors
This change will decrease hot path cost.
Signed-off-by: snowapril <sinjihng@gmail.com>
This commit fixes `test_global_parap_err_first` test in
[test_syntax.py](https://github.com/RustPython/RustPython/blob/master/Lib/test/test_syntax.py#L678) and implement the other syntax errors detection as cpython 3.8 provided for global symbol.
Below syntax error conditions are added.
* name {} is parameter and global
```python
>>>>> def test(a):
..... global a
.....
SyntaxError: name 'a' is parameter and global at line 2 column 2
global a
```
* annotated name {} can't be global
```python
>>>>> def test():
..... a: int
..... global a
.....
SyntaxError: annotated name 'a' can't be global at line 3 column 2
global a
```
* name {} is assigned to before global description
```python
>>>>> a = 100
>>>>> def test():
..... a = 10
..... global a
.....
SyntaxError: name 'a' is assigned to before global declaration at line 3 column 2
global a
```
* name {} is used prior to global declaration
```python
>>>>> a = 10
>>>>> def test():
..... print(a)
..... global a
.....
SyntaxError: name 'a' is used prior to global declaration at line 3 column 2
global a
```
Signed-off-by: snowapril <sinjihng@gmail.com>
* Initial implementation of named expression and import according CPython tests
* added new instruction with inversed evaluation order for dict comprehension, in other cases use regular evaluation order
* added further aspects to implementation, cleaned up, imported test from CPython
* implemented first parts of scoping enhancement and extended checks
* completion of name resolution ongoing, now more test passing, still warinings and cleanup required
* further optimization of name resolution in nested scopes
* Initialize the vm with imports from _io instead of io
* Add the OpenBSD support that I am smart enough to
* adapted grammer to full support, most test are passing now, esp. all invalids are passed. Cleaned up in symboltable
* more conditional compiling, this time for errors
* rustfmt was not pleased
* premature push, whoops
* Add expected_failure result type to jsontests
* Initial implementation of named expression and import according CPython tests
* added new instruction with inversed evaluation order for dict comprehension, in other cases use regular evaluation order
* added further aspects to implementation, cleaned up, imported test from CPython
* implemented first parts of scoping enhancement and extended checks
* completion of name resolution ongoing, now more test passing, still warinings and cleanup required
* further optimization of name resolution in nested scopes
* adapted grammer to full support, most test are passing now, esp. all invalids are passed. Cleaned up in symboltable
* Fixed nameing convention violation and removed unnecessary information from symbol resolution. Added some more comments.
* Fixed nameing convention violation and removed unnecessary information from symbol resolution. Added some more comments.
Co-authored-by: Noah <33094578+coolreader18@users.noreply.github.com>
Co-authored-by: Reuben Staley <lighthousemaniac@gmail.com>