From 35230b1a11940117ee218066ef5cd11243a23456 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 8 Jul 2021 23:15:07 +0100 Subject: Add "Suggestion: Did you mean?" for selector expression typos --- src/check_builtin.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/check_builtin.cpp') 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) { -- cgit v1.2.3