rhai: Unhelpful error when trying to call a non-existing function or with wrong signature
The returned error when trying to call a function implemented in Rust with either incorrect name or incorrect signature is not helpful. E.g.
Function not found: add_param_setting (rusp::usp_builder::add::CreateObjectBuilder, &str | ImmutableString | String, &str | ImmutableString | String, i64) (line 5, position 10)
It’s basically throwing back at you what you’re trying to do without any hints about what might be wrong with it.
I guess in the interest of space we don’t want to do some guesswork to find the correct fix and make a suggestion. But it would be nice to at least detect whether the function doesn’t exist at all (i.e. wrong function name) or the function does exist but has a non-matching signature.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 21
Yes you’re correct. It should yield the namespace of the function.
I can add it.
@schungx This minimal example:
yields the following output:
my expectation would be that info.namespace should contain
"math". Am I misunderstanding the API here?@schungx I’m finally getting around to working on this, and I’m already quite close to having something neatly usable:
However, it seems that the info that I get access to in collect_fn_metadata doesn’t ever contain the name of the containing namespace of the function – this means that I can neither somehow filter by namespace, nor properly show the namespace of a given function in the suggestion output (which would be useful for cases where I want to display “did you mean this similarly named function”-style errors) Specifically, I don’t see the namespace name for any namespaces that are defined in my code, through the
register_static_module-api.Additionally, it’d of course be very useful to have some more structured information in the EvalAltResult directly, as currently I effectively need to parse the signature that I get – which works, but feels a bit ugly and somewhat fragile. The main blocker right now is the namespace name availability though.
Yes, it contains everything to know about a function including all the parameter types and names.