ta0kira / zeolite

Zeolite is a statically-typed, general-purpose programming language.
Apache License 2.0
18 stars 0 forks source link

Don't include function filters when guessing types. #72

Closed ta0kira closed 4 years ago

ta0kira commented 4 years ago

guessParamsFromArgs includes filters from the function's params. This could cause issues if the scope where the function is called has a param of the same name.

concrete Type1<#x> {
  @type call () -> ()
}

concrete Type2 {
  @type call<#x> () -> ()
}

define Type1 {
  call () {
    // Name clash with #x.
    \ Type2$call<?>()
  }
}

It shouldn't be much of an issue currently because Map.union is left-biased and the function params are included on the right.

It might not even be possible currently for those filters to affect the outcome; I can't think of a situation where they'd even be looked up. (Needs a fix and some tests, either way.)

ta0kira commented 4 years ago

As it turns out, there was a related issue where the param filters of the parent scope were being used as guesses, which was causing a clash.

So, in 0.7.0.0, there is a bug that should only occur if the parent scope has a param with the same name as the function being called, and the former has a non-defines filter with that param on the left. (Using the example above, if Type1 had a filter #x requires Foo, etc.)

ta0kira commented 4 years ago

Note that the parser example uses a lot of inference, and nearly all of the params are #x, with a few #y. So, it in theory mostly works right now.

ta0kira commented 4 years ago

As it turns out, it looks like assignFunctionParams might have a similar issue with param clashes.

ta0kira commented 4 years ago

Also see #73.