argotorg / solcore

experimental solidity compiler
13 stars 1 forks source link

Defunctionalisation yields too general types #33

Open mbenke opened 1 month ago

mbenke commented 1 month ago

In test/examples/cases/Compose.solc function main gets too general type:

  function main() {
    let f = compose(id,id);
    return f(42);
  }

we get

Results: main :: forall a67 . a67
Annotated AST:
   function main () -> a67 {
      let f = compose(id, id) ;
      return invokable.invoke(f, 42)
   }

this may be related to the fact that the composition gets a very loose type:

function idid() { return compose(id,id); }
Results: idid :: forall a56 a57 a53 a54 . LambdaTy0(a56 -> a56, a57 -> a57, a53, a54)

where the types of functions being composed are unrelated neither to themselves nor to the argument and result of the composition; I would expect something along the lines

idid :: forall a .  LambdaTy0(a -> a, a -> a, a, a)

also the type of compose itself seems too general:

compose :: forall a26 a27 a28 a29 . a26 -> a27 -> LambdaTy0(a26, a27, a28, a29)