-
-
Notifications
You must be signed in to change notification settings - Fork 82
Provide suggestions if a function cannot be found #412
Copy link
Copy link
Closed
Labels
exp: lowAchievable with little prior knowledge and guidanceAchievable with little prior knowledge and guidancegood first issueGood for newcomersGood for newcomerstype: featNew feature or requestNew feature or request
Milestone
Description
If a mun function cannot be found when trying to execute some Mun code via the runtime, include suggestions of correct function names.
Current Behaviour
mun/crates/mun_runtime/tests/functions.rs
Lines 6 to 28 in cc839c3
| #[test] | |
| fn unknown_function() { | |
| let driver = CompileAndRunTestDriver::new( | |
| r" | |
| pub fn main() -> i32 { 5 } | |
| ", | |
| |builder| builder, | |
| ) | |
| .expect("Failed to build test driver"); | |
| const EXPECTED_FN_NAME: &str = "may"; | |
| let result: Result<i32, _> = driver.runtime.invoke(EXPECTED_FN_NAME, ()); | |
| let err = result.unwrap_err(); | |
| assert_eq!( | |
| err.to_string(), | |
| format!( | |
| "failed to obtain function '{}', no such function exists.", | |
| EXPECTED_FN_NAME | |
| ) | |
| ); | |
| } |
Desired behavour
The returned error message contains an additional line recommending the function name/path that's the closest match, something like:
help: there is a function with a similar name: `main`
Good first issue process:
- read our contributing guidelines
- You can fork this branch, which already contains a test to help you get started
- claim this issue (assign yourself or comment below)
- implement the feature and start a Pull Request with in the description: closes Provide suggestions if a function cannot be found #412.
If this is your first PR, welcome 🎉 😄
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
exp: lowAchievable with little prior knowledge and guidanceAchievable with little prior knowledge and guidancegood first issueGood for newcomersGood for newcomerstype: featNew feature or requestNew feature or request