Skip to content

Provide suggestions if a function cannot be found #412

@baszalmstra

Description

@baszalmstra

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

#[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:

If this is your first PR, welcome 🎉 😄

Metadata

Metadata

Assignees

Labels

exp: lowAchievable with little prior knowledge and guidancegood first issueGood for newcomerstype: featNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions