Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test / TODO for a bug in
__init__
Summary: I noticed this in the middle of a refactor, and it's not convenient to fix until I finish the refactor, but recording a test case. The correct semantics here aren't 100% clear, but you can see the runtime behavior [here]( https://codapi.org/embed/?sandbox=python&code=data%3A%3Bbase64%2CSyvKz1UoqSzIzEtXyMwtyC8qUQipLEhNcclMLtFR8MsvCUotLM0sSk3h4krOSSwuVnDRgMtrWnEpgECFlUJmXgmEXQlmK9gqmEL4VVbIhkRn5pXEcnFxFRRl5pVouGhoagIA), the constructor call allows anything, which means that - we almost certainly should allow `z` to be missing - we probably should also complain about `y` missing, the generated `__init__` does *not* use the default value. I think this bug is caused by incorrect sharing of code between dataclass and typed dict logic, where we shared the code because the operations look the same in the Rust type system, but the actual Python semantics are divergent. I found this working on a refactor to hide internals of `ClassField`, which has the side effect of encouraging TypedDict and dataclass to actually own thier own behavior instead of farming out logic to an overly abstract helper method, which will naturally make it easy to fix this on top of my refactor. Reviewed By: ndmitchell Differential Revision: D70057864 fbshipit-source-id: 52b2aef295b5ee2b3f7b903e04ee32fe51bc2d50
- Loading branch information