rodrigogribeiro / solcore

1 stars 2 forks source link

Type mismatch in Typed Params #6

Closed mbenke closed 1 month ago

mbenke commented 1 month ago

Consider functions (see https://github.com/rodrigogribeiro/solcore/blob/specialisation/test/examples/spec/03join.solc)

  function just(x) { return Some[x]; }

  function maybe(n, o) {
    match o {
      | None => return n;
      | Some[x] => return x;
    };
  }

  function join(mmx) {
    match mmx {
      | Some[Some[x]] => return Some[x];
      | _ => return None;
    };
  }

They seem to be typed properly

Results: just :: forall a . a -> Option[a]
Results: maybe :: forall a . a -> Option[a] -> a
Results: join :: forall a . Option[Option[a]] -> Option[a]

...but the types in their arguments seem mismatched

Signature {
sigName = just,
sigContext = [],
sigParams = [
         Typed (Id {idName = x, idType = TyVar (TVar j)}) (TyVar (TVar i))
        ],
sigReturn = Just (TyCon Option [TyVar (TVar j)])}

in the Typed a t the idType a says the type is "j", but type t says "i"

Similarly for maybe

Signature { sigName = maybe, sigContext = [], 
   sigParams = [ Typed (Id {idName = n, idType = TyVar (TVar r)}) (TyVar (TVar n))
               , Typed (Id {idName = o, idType = TyCon Option [TyVar (TVar r)]}) (TyVar (TVar o))
               ], 
  sigReturn = Just (TyVar (TVar r))} 
rodrigogribeiro commented 1 month ago

Fixed on last commit in main.