diff options
| author | gingerBill <bill@gingerbill.org> | 2021-07-08 23:15:07 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-07-08 23:15:07 +0100 |
| commit | 35230b1a11940117ee218066ef5cd11243a23456 (patch) | |
| tree | 8e3cc3ec2b5efd40352897bd5d5bbcccb60d1fbf /src/check_builtin.cpp | |
| parent | 7acbf8b7b9cfc1f3e63d330e4dac13b28f1310f2 (diff) | |
Add "Suggestion: Did you mean?" for selector expression typos
Diffstat (limited to 'src/check_builtin.cpp')
| -rw-r--r-- | src/check_builtin.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index ea48c7ade..d9dd2be03 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -580,6 +580,11 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 error(ce->args[0], "'%s' has no field named '%.*s'", type_str, LIT(arg->token.string)); gb_string_free(type_str); + + Type *bt = base_type(type); + if (bt->kind == Type_Struct) { + check_did_you_mean_type(arg->token.string, bt->Struct.fields); + } return false; } if (sel.indirect) { @@ -3082,6 +3087,10 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 error(ce->args[0], "'%s' has no field named '%.*s'", type_str, LIT(field_name)); gb_string_free(type_str); + + if (bt->kind == Type_Struct) { + check_did_you_mean_type(field_name, bt->Struct.fields); + } return false; } if (sel.indirect) { |