Skip to content

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

Merged
Wodann merged 6 commits intomun-lang:mainfrom
belagoesr:improvement/function-suggestions-issue-412
Jun 1, 2023
Merged

feat: provide suggestions if a function cannot be found#524
Wodann merged 6 commits intomun-lang:mainfrom
belagoesr:improvement/function-suggestions-issue-412

Conversation

@belagoesr
Copy link
Copy Markdown
Contributor

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

@Wodann Wodann requested review from Wodann and baszalmstra May 30, 2023 01:29
Copy link
Copy Markdown
Collaborator

@Wodann Wodann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome! Just one nitpick

@codecov
Copy link
Copy Markdown

codecov bot commented May 30, 2023

Codecov Report

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

❗ 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%) ⬆️
crates/mun_runtime/src/lib.rs 79.22% <100.00%> (+3.31%) ⬆️

... and 2 files with indirect coverage changes

Copy link
Copy Markdown
Collaborator

@Wodann Wodann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@belagoesr
Copy link
Copy Markdown
Contributor Author

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

sounds good thanks!

Copy link
Copy Markdown
Collaborator

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I left some small comments.

}

/// Retrieves the name of all available functions.
pub fn get_fn_names(&self) -> Vec<&str> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also return an iterator to avoid allocating memory for the vec

@belagoesr
Copy link
Copy Markdown
Contributor Author

Looks good to me! I left some small comments.

Just pushed the changes!

Copy link
Copy Markdown
Collaborator

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

@Wodann Wodann merged commit d487bd0 into mun-lang:main Jun 1, 2023
@Wodann Wodann added this to the Mun v0.5.0 milestone Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide suggestions if a function cannot be found

3 participants