Skip to content

Add literal math support for shift operators #517

@correctmost

Description

@correctmost

Summary

ty doesn't currently perform "literal math" when using the left and right shift operators:

from typing import reveal_type

reveal_type(2<<2)  # int
reveal_type(2>>2)  # int

This seems like an inconsistency given the support for other operators. (Pyright has support for both shift operators.)

The Python docs note that "Negative shift counts are illegal and cause a ValueError to be raised".

Version

ty 0.0.1-alpha.7

Metadata

Metadata

Assignees

Labels

runtime semanticsAccurate modeling of how Python's semantics work at runtime

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions