mun-lang / mun

Source code for the Mun language and runtime.
https://mun-lang.org
Other
1.81k stars 72 forks source link

feat: provide suggestions if a function cannot be found #524

Closed belagoesr closed 1 year ago

belagoesr commented 1 year ago

If a function is not found, a suggestion is added to the error message if a close match exists. To measure if there is a close match, the difference between the names are measured using Levenshtein distance, the approach is based on here: https://github.com/rust-lang/rust/blob/488acf86a75c56d30b16822e953c505a9e4901a7/compiler/rustc_span/src/lev_distance.rs#L46-L48

Fixes: #412

codecov[bot] commented 1 year ago

Codecov Report

Merging #524 (a243d3b) into main (7912e0c) will increase coverage by 0.10%. The diff coverage is 96.42%.

:exclamation: Current head a243d3b differs from pull request most recent head ef94d4b. Consider uploading reports for the commit ef94d4b to get more accurate results

@@            Coverage Diff             @@
##             main     #524      +/-   ##
==========================================
+ Coverage   87.05%   87.15%   +0.10%     
==========================================
  Files         274      275       +1     
  Lines       31028    31082      +54     
==========================================
+ Hits        27011    27090      +79     
+ Misses       4017     3992      -25     
Impacted Files Coverage Δ
crates/mun_runtime/src/utils.rs 92.00% <92.00%> (ø)
crates/mun_runtime/src/dispatch_table.rs 96.66% <100.00%> (+0.37%) :arrow_up:
crates/mun_runtime/src/lib.rs 79.22% <100.00%> (+3.31%) :arrow_up:

... and 2 files with indirect coverage changes

belagoesr commented 1 year ago

LGTM! I'll let @baszalmstra have a look too before merging

sounds good thanks!

belagoesr commented 1 year ago

Looks good to me! I left some small comments.

Just pushed the changes!