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

SimType & friends: Fully typecheck, fix observed bugs #4610

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rhelmot
Copy link
Member

@rhelmot rhelmot commented Apr 25, 2024

This involved making several classes NOT subclasses of other classes, since doing so would violate the Liskov Substitution Principle. Several bugs were discovered while making these changes, they were all fixed.

Type-checking was done with pyright.

@rhelmot rhelmot requested a review from ltfish April 25, 2024 22:20
@ltfish
Copy link
Member

ltfish commented Apr 25, 2024

What do you think of using from __future__ import annotations?

@rhelmot
Copy link
Member Author

rhelmot commented Apr 25, 2024

Done

not isinstance(base_type, SimTypeBottom)
and not isinstance(data_type, SimTypeBottom)
and base_type.size < data_type.size
base_type.size is not None and data_type.size is not None and base_type.size < data_type.size
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the new way of testing if something is a bottom type .size is None?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a superset of that check. This code will fail on any unsizable type so that's what I'm checking for.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are all the types that can be unsized? SimTypeBottom and SimStructs without an arch specified?

@ltfish
Copy link
Member

ltfish commented Apr 26, 2024

By the way I find the (name of the) SimTypeReg class a bit misleading since some of its subclasses, such as SimTypeChar, are not necessarily register-sized.

@ltfish ltfish added the refactor Something needs to be reorganized label Apr 26, 2024
@rhelmot
Copy link
Member Author

rhelmot commented Apr 26, 2024

for some inconceivable reason, some of the numeric types allow parametrizing themselves with size=None, and there are in fact cases to handle this strewn about the simtype code, so I can only assume this is actually used.

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

Successfully merging this pull request may close these issues.

None yet

2 participants