350b7b49b6
When an identifier is used as an upvalue within a nested scope (e.g., a `while` loop), the type checker needs to apply the global substitution map to resolve `TypeVar`s that might have been determined in outer scopes. This ensures that the correct type is used even if `ctx.set_type` couldn't propagate the change directly through the upvalue address. This fix also includes a regression test to specifically cover this scenario with series and closures.