facebook / facebook/pyrefly

Allow global before variable is defined

Open
#1,700 4 comments 0 reactions 0 assignees View on GitHub
needs-discussion typechecking
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

```python
def main():
global table
table = 1
print(table)

main()
```

This works fine, but Pyrefly complains `Could not find name "table"`

### Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIAOljGAAQC2qE6AFAJSLV090DmUXNlRQ6AF1TZY3XhKkw6AXjoBGGT2IAnFmNZzY7atSYsOIADQgArmOhwS5RCADEdAKq2oEMaTpgr6ADGtrjocEY09GC4mkxiAProVgzYMJqs%2BIh0Oux0ALQAfHRwYppc6Lx0mjBiVpoVYJQgAHLJqWV0wPgAvk3UFiBk1WBQpIRiuAxQFK4ACqTDo8UYOAR0gaGQfHWoIeiE1K4AyjAKABZiYsRwiAD0t0O0o4QxfLcw6LeYuIFwtxvoLY7Pa3PwxOioABuzCgklg602EG2ml2EFCdFwxD29moZDEZ1CeUhaTgaIqyiaAGZCCoAEx9dAgbqWVDBCDEgBi0BgFDQWDwRDITKAA

### (Only applicable for extension issues) IDE Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.