mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Include @name when searching for possible matches to name in the error message. #1779
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
- Add 'validation' setting and make dead code a warning.
|
||||
- Allow compile time `$foreach` iteration over constant Strings and bytes.
|
||||
- Improved error message when accessing `@private` from other modules #1769.
|
||||
- Include `@name` when searching for possible matches to `name` in the error message. #1779
|
||||
|
||||
### Fixes
|
||||
- Fix case trying to initialize a `char[*]*` from a String.
|
||||
|
||||
@@ -546,10 +546,18 @@ static void find_closest(const char *name, int name_len, Decl **decls, int *coun
|
||||
{
|
||||
int best_distance = *best_distance_ref;
|
||||
int count = *count_ref;
|
||||
bool starts_at = name[0] == '@';
|
||||
Decl *at_match = NULL;
|
||||
FOREACH(Decl *, decl, decls)
|
||||
{
|
||||
if (decl->visibility != VISIBLE_PUBLIC) continue;
|
||||
int dist = damerau_levenshtein_distance(name, name_len, decl->name, strlen(decl->name));
|
||||
const char *decl_name = decl->name;
|
||||
if (!starts_at && decl_name[0] == '@' && str_eq(&decl_name[1], name))
|
||||
{
|
||||
at_match = decl;
|
||||
continue;
|
||||
}
|
||||
int dist = damerau_levenshtein_distance(name, name_len, decl_name, strlen(decl_name));
|
||||
if (dist < best_distance)
|
||||
{
|
||||
matches[0] = decl;
|
||||
@@ -562,6 +570,17 @@ static void find_closest(const char *name, int name_len, Decl **decls, int *coun
|
||||
matches[count++] = decl;
|
||||
}
|
||||
}
|
||||
if (at_match)
|
||||
{
|
||||
if (count == 3)
|
||||
{
|
||||
matches[0] = at_match;
|
||||
}
|
||||
else
|
||||
{
|
||||
matches[count++] = at_match;
|
||||
}
|
||||
}
|
||||
*count_ref = count;
|
||||
*best_distance_ref = best_distance;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user