quint icon indicating copy to clipboard operation
quint copied to clipboard

Variables and Constant should not be allowed to have quantified type variables

Open konnov opened this issue 1 year ago • 6 comments

I have accidentally introduced a type error in the variable declaration:

// it should be:
// var erc20State: Erc20State
var erc20State: erc20State

https://github.com/informalsystems/quint/blob/56abbcd46437c8b515b7c7b50e4dc1b899da61ab/examples/solidity/ERC20/erc20.qnt#L244-L257

The type checker did not detect a problem in the variable declaration. Moreover, I had a type error in the following action:

https://github.com/informalsystems/quint/blob/56abbcd46437c8b515b7c7b50e4dc1b899da61ab/examples/solidity/ERC20/erc20.qnt#L253-L257

We should figure out, what is going on with the type checker.

konnov avatar Apr 07 '23 17:04 konnov

I understand the problem! Our language manual specifyies:

Uninterpreted type or type name: IDENTIFIER_IN_CAPS. Type variable (parameter): a, ..., z.

So erc20State here is parsed as a (quantified) type variable.

This is actually a language design problem 😅 Should we prevent state variables to have quantified type variables at all? @konnov

bugarela avatar Apr 13 '23 12:04 bugarela

So erc20State here is parsed as a (quantified) type variable.

This is actually a language design problem 😅 Should we prevent state variables to have quantified type variables at all? @konnov

Oh, wow. Yes, we cannot do much about polymorphic state variables. This should be caught by the type checker.

konnov avatar Apr 14 '23 07:04 konnov

Ok! I'll change the issue name to reflect the specifics of what the type checker misses.

bugarela avatar Apr 14 '23 11:04 bugarela

I'll also add this check to constants as we discussed at some quint meeting.

bugarela avatar Apr 14 '23 12:04 bugarela

As a special case of this we should not allow declaration of these to include free row variables. This is currently accepted:

    var rec1: { f1: int, f2: str | r1 }
    var rec2: { f2: str, f3: bool | r2 }

shonfeder avatar Jul 24 '23 17:07 shonfeder

This is related to #456 and can probably be fixed at the same time. It is another case where we are allowing type annotations for things that cannot be values (nothing can have type 'a since we don't have a bottom or non-termination).

shonfeder avatar Oct 02 '23 17:10 shonfeder