diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2026-02-13 15:15:03 +0100 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2026-02-13 15:15:03 +0100 |
| commit | 6386b395de7e0e537e092601ff0ac4d353806ebb (patch) | |
| tree | 80d44c794e9a4d13dedc2479db832e4f7eb1bb0f /src/check_expr.cpp | |
| parent | f7f19e5ebe45547732c2af39aa7f71feefd76f72 (diff) | |
Add `-did-you-mean-limit:N`
```
-did-you-mean-limit:<integer>
Sets the maximum number of suggestions the compiler provides.
Must be an integer >0.
If not set, the default limit is 10.
```
e.g. with a limit of 5
```
W:/Scratch/main.odin(44:7) Error: Undeclared name 'B1' for type 'E'
e = .B1
^^
Suggestion: Did you mean?
A23
A02
A19
A20
A21
... and 25 more ...
```
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 1c09ad908..f2cdcc2ea 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -153,13 +153,19 @@ gb_internal bool is_load_directive_call(Ast *call) { gb_internal LoadDirectiveResult check_load_directive(CheckerContext *c, Operand *operand, Ast *call, Type *type_hint, bool err_on_not_found); gb_internal void check_did_you_mean_print(DidYouMeanAnswers *d, char const *prefix = "") { + int limit = build_context.did_you_mean_limit; auto results = did_you_mean_results(d); + int count = 0; if (results.count != 0) { error_line("\tSuggestion: Did you mean?\n"); for (auto const &result : results) { String const &target = result.target; error_line("\t\t%s%.*s\n", prefix, LIT(target)); // error_line("\t\t%.*s %td\n", LIT(target), results[i].distance); + if (limit > 0 && ++count == limit) { + error_line("\t\t... and %td more ...", results.count - limit); + break; + } } } } |