-
Notifications
You must be signed in to change notification settings - Fork 37
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
Fix our dear #693 type checker bug #1166
Conversation
@@ -491,7 +491,8 @@ module state { | |||
val poll = state.polls.get(poll_id) | |||
poll.options.listForall(option => | |||
val optionKey = option._1 | |||
val optionSum = option._2 | |||
// FIXME: Type annotation below is a workaround, inferred type is too general | |||
val optionSum: int = option._2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This specific case seems different from the others. I'll look at it in a separate issue (to be created). Every other FIXME of this kind has been removed 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is amazing, great work!
Changes to the typechecker LGTM.
Could you explain where we need the row type simplifier?
afaik, nested rows are already flattened on the Apalache side:
https://github.com/informalsystems/apalache/blob/315d43ad3afca3ed3abbb5e8f2610e3bd9bc9929/tla-io/src/main/scala/at/forsyte/apalache/io/quint/QuintTypeConverter.scala#L60-L73
I've also pushed a small commit to get rid of a reference to #693 in one of the RFCs.
Interesting, I didn't realize we are already doing this in Apalache. So... I've added this simplification step because I was hitting an error where Apalache complained about mismatching row types, something like "expected Var or Empty, found Row", which I instantly interpreted as nested rows and jumped to a fix. However, I can't reproduce that anymore 🤔. Perhaps it was caused by some intermediate state of my other fix or something like that. While trying to decide if this simplification is worth keeping, I noticed we do similar processes both before printing rows and before unifying rows. So I'll extract it from this PR and just add it in a separate cleanup PR accounting for all these scenarios. |
Co-authored-by: Thomas Pani <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, LGTM!
Hello
This fixes #693!
The problem was: even though type variables for parameters are free, we were failing to keep track of this fact after substitutions. So, considering the example:
Suppose
x
has type variablet0
, which is free. Once we analyzex.keys()
, we'll perform a unification and apply substitutions, resulting int0
being replaced byt1 -> t2
(sincex
has to be a map in order for it to be an argument forkeys()
). However, sincet1
andt2
are not free names, when we exit the let definition, the types are quantified, and we loose track that those types are related to the parameter type.The solution is to make sure that, in a substitution like
t0 |-> t1 -> t2
, ift0
is a free variable, thent1
andt2
also have to be free.Also, I found another small bug in the integration with Apalache due to the different representation of row types between quint and apalache. The Apalache representation doesn't allow nested rows (that is, a concrete row in the tail). This also adds a small fix for that.
CHANGELOG.md
for any new functionalityREADME.md
updated for any listed functionality