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

Get rid of CheckedType::UnknownType #143

Open
flip1995 opened this issue Nov 24, 2018 · 9 comments
Open

Get rid of CheckedType::UnknownType #143

flip1995 opened this issue Nov 24, 2018 · 9 comments
Labels
enhancement New feature or request refactor Changes that do not change the functional behaviour wontfix This will not be worked on
Projects

Comments

@flip1995
Copy link
Contributor

otherwise, to get exhaustive enum matches, we need to take care of this, wherever we match on CheckedType

See #141 (comment)

@joshuabach
Copy link
Contributor

joshuabach commented Nov 25, 2018

If I understood @hediet correctly, UnknownType is constructed if an undefined class is used (an error is obviously also generated). This needs to be represented somehow because we want to continue checking even in case of this error. I don't think we can easily get rid of this. This case can be handled as unreachable!() or sth similar in the IR generation, since that is only called if no error occured

@hediet
Copy link
Member

hediet commented Nov 25, 2018

Better having an explicit UnknownType than having TypeRefs which point to nothing. Either way, you need to panic if something is wrong (calling expect on the result of a type lookup or asserting unreachable for UnknownTypes). I strongly prefer the UnknownType variant.

@flip1995
Copy link
Contributor Author

While looking through the code I couldn't figure out a way to get rid of this. A TypeRef pointing to nothing is indeed not a good solution. But having to return None or panic isn't either. The later is for now better, but still not optimal.

@flip1995 flip1995 added enhancement New feature or request refactor Changes that do not change the functional behaviour labels Nov 25, 2018
@hediet
Copy link
Member

hediet commented Nov 25, 2018

What would an "optimal" solution look like? As long as we construct CheckedTypes for possibly invalid types, we need to consider that these CheckedTypes actually may represent invalid types.

@flip1995
Copy link
Contributor Author

Removing the UnknownType. Maybe replacing it with an Option in checked_type_from_basic_ty. I don't really know. But this is low prio, since we can always return None in the firm generation when matching CheckedType (currently we even have to do this for CheckedType::Void anyway, since the void type is forbidden everywhere except return types).

@reiner-dolp
Copy link
Contributor

In my opinion there should be just a second typesystem struct that is "into()"ed at the end of the semantic analysis phase that has all this impossible states removed.

@hediet
Copy link
Member

hediet commented Nov 29, 2018

In my opinion there should also be a second ast for that.

@reiner-dolp
Copy link
Contributor

reiner-dolp commented Nov 29, 2018

You are actually right. Most of the impossible states are in the ast. @hediet what are you thinking of exactly? A reshaped ast with typesystem information on each node?

@hediet
Copy link
Member

hediet commented Nov 29, 2018

@reiner-dolp yes, exactly.

@joshuabach joshuabach added this to the Semantical Analysis milestone Dec 3, 2018
@joshuabach joshuabach added the wontfix This will not be worked on label Dec 3, 2018
@problame problame added this to Todo !(optimization OR backend) in Endspurt Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor Changes that do not change the functional behaviour wontfix This will not be worked on
Projects
Endspurt
  
General Todo
Development

No branches or pull requests

4 participants