pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

Incorrect understanding of `global` in inner function

Open grievejia opened this issue 10 months ago • 0 comments

Describe the Bug

Minimal repro:

x: int = 1

def outer():
    x: str = ""

    def inner():
        global x
        reveal_type(x)

Expected: Reveals str Actual:

  • Found x, but it was not the global scope
  • Reveals str

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

grievejia avatar May 18 '25 18:05 grievejia