Skip to content

Any declaration before loop ignored #3046

Description

@MarcoGorelli

Describe the Bug

from typing import Protocol, Sequence, reveal_type, Literal, Any
from enum import Enum

def main() -> None:
    a: Any
    for a in ('b', 3, {'a': 1}):
        reveal_type(a)
(scratch) marcogorelli@DESKTOP-U8OKFP3:~/scratch$ pyright t.py
/home/marcogorelli/scratch/t.py
  /home/marcogorelli/scratch/t.py:7:21 - information: Type of "a" is "Any"
0 errors, 0 warnings, 1 information
(scratch) marcogorelli@DESKTOP-U8OKFP3:~/scratch$ pyrefly check t.py
 INFO revealed type: Literal['b', 3] | dict[Any, Any] [reveal-type]
 --> t.py:7:20
  |
7 |         reveal_type(a)
  |                    ---
  |
 INFO 0 errors

I think I'd expect Any here too?

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-discussionAn issue where it's not clear whether there is a bug or we are behaving as expected.quansighttypechecking

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions