stan-dev / stanc3

The Stan transpiler (from Stan to C++ and beyond).
BSD 3-Clause "New" or "Revised" License
140 stars 44 forks source link

sort type errors by comparing to input type #1307

Closed nhuurre closed 1 year ago

nhuurre commented 1 year ago

When typecheck fails for an overloaded Stan Math function, the five signatures listed aren't always the most relevant ones. This PR changes the error sorting heuristic to prefer the types that have a similar shape to the one supplied by the user. See bernoulli_logit in the tests for an example of how it looks.

Submission Checklist

Release notes

Copyright and Licensing

Copyright holder: Niko Huurre By submitting this pull request, the copyright holder is agreeing to license the submitted work under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause)

codecov[bot] commented 1 year ago

Codecov Report

Merging #1307 (08baffa) into master (c435684) will increase coverage by 0.01%. The diff coverage is 84.61%.

@@            Coverage Diff             @@
##           master    #1307      +/-   ##
==========================================
+ Coverage   89.00%   89.01%   +0.01%     
==========================================
  Files          64       64              
  Lines        9773     9777       +4     
==========================================
+ Hits         8698     8703       +5     
+ Misses       1075     1074       -1     
Impacted Files Coverage Δ
src/middle/UnsizedType.ml 76.22% <66.66%> (+1.63%) :arrow_up:
src/frontend/SignatureMismatch.ml 82.22% <90.00%> (-0.14%) :arrow_down: