diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2026-02-08 23:53:36 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2026-02-08 23:53:36 -0500 |
| commit | b6372ef6cc7b9727bc90946e91c85e2749dc372d (patch) | |
| tree | eef7a1265a3eb3bf25ae306f00abe01a82bd637d /src/compile/functions.c | |
| parent | 4e31786efcf32818a620cc87ffa80dadef90a466 (diff) | |
Add a "did you mean?" suggestion for invalid field/method names.
Diffstat (limited to 'src/compile/functions.c')
| -rw-r--r-- | src/compile/functions.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/compile/functions.c b/src/compile/functions.c index f62e00f8..2db419d2 100644 --- a/src/compile/functions.c +++ b/src/compile/functions.c @@ -941,7 +941,10 @@ Text_t compile_method_call(env_t *env, ast_t *ast) { type_t *fn_t = get_method_type(env, methodcall->self, methodcall->name); arg_ast_t *args = new (arg_ast_t, .value = methodcall->self, .next = methodcall->args); binding_t *b = get_namespace_binding(env, methodcall->self, methodcall->name); - if (!b) code_err(ast, "No such method"); + if (!b) { + OptionalText_t suggestion = suggest_best_name(call->name, get_method_names(env, self_value_t)); + code_err(ast, "No such method!", suggestion); + } return Texts(b->code, "(", compile_arguments(env, ast, Match(fn_t, FunctionType)->args, args), ")"); } } |
