Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Covariance permits illogical assignments #1

Open
buge opened this issue Aug 29, 2021 · 0 comments
Open

Covariance permits illogical assignments #1

buge opened this issue Aug 29, 2021 · 0 comments

Comments

@buge
Copy link
Owner

buge commented Aug 29, 2021

Because we model only non-zero dimensions, it's currently possible to assign incompatible quantities to one another due to their type covariance:

const speed: Quantity<{length: 1, seconds: -1}> = metersPerSecond(5);
const length: Quantity<{length: 1}> = speed; // ouch

While we can't protect against this for all user-defined dimensions, we should look into making at least the built-in dimensions more robust by modeling known dimensions with exponent 0. I need to think through all the possible corner-cases though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant