pyrefly
pyrefly copied to clipboard
[feature] error when NamedTuple field without a default appears after any NamedTuple field with default
Describe the Bug
From the typing spec:
The runtime implementation of NamedTuple enforces that fields with default values must come after fields without default values. Type checkers should likewise enforce this restriction
Here is the code that needs to change:
https://github.com/facebook/pyrefly/blob/main/pyrefly/lib/alt/class/named_tuple.rs#L30
Once this is done, please add a test to: https://github.com/facebook/pyrefly/blob/main/pyrefly/lib/test/named_tuple.rs
Sandbox Link
https://pyrefly.org/sandbox/?code=GYJw9gtgBALgngBwJYDsDmUkQWEMoByAhhAKYAmAKgK4IA2pAUIwMZ1EDOHUAYmGAApiZKrQYBKAFyMosqAA9JmFPgC8UAIwy5cJanxQAxFEoALJNw6mw1OuSikQ4EEA
(Only applicable for extension issues) IDE Information
No response