mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 10:49:54 +00:00
fix: distinguish between access to class/instance attr
This commit is contained in:
parent
1cbe2de706
commit
d4b78eb020
10 changed files with 233 additions and 80 deletions
|
@ -485,11 +485,12 @@ impl LowerError {
|
|||
) -> Self {
|
||||
let hint = similar_name.map(|n| {
|
||||
let vis = similar_info.map_or("".into(), |vi| vi.vis.modifier.display());
|
||||
let kind = similar_info.map_or("", |vi| vi.kind.display());
|
||||
switch_lang!(
|
||||
"japanese" => format!("似た名前の{vis}属性があります: {n}"),
|
||||
"simplified_chinese" => format!("具有相同名称的{vis}属性: {n}"),
|
||||
"traditional_chinese" => format!("具有相同名稱的{vis}屬性: {n}"),
|
||||
"english" => format!("has a similar name {vis} attribute: {n}"),
|
||||
"japanese" => format!("似た名前の{vis}{kind}属性があります: {n}"),
|
||||
"simplified_chinese" => format!("具有相同名称的{vis}{kind}属性: {n}"),
|
||||
"traditional_chinese" => format!("具有相同名稱的{vis}{kind}屬性: {n}"),
|
||||
"english" => format!("has a similar name {vis} {kind} attribute: {n}"),
|
||||
)
|
||||
});
|
||||
let found = StyledString::new(name, Some(ERR), Some(ATTR));
|
||||
|
@ -1157,4 +1158,30 @@ impl LowerWarning {
|
|||
caused_by,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn same_name_instance_attr_warning(
|
||||
input: Input,
|
||||
errno: usize,
|
||||
loc: Location,
|
||||
caused_by: String,
|
||||
name: &str,
|
||||
) -> Self {
|
||||
let name = StyledStr::new(readable_name(name), Some(WARN), Some(ATTR));
|
||||
Self::new(
|
||||
ErrorCore::new(
|
||||
vec![SubMessage::only_loc(loc)],
|
||||
switch_lang!(
|
||||
"japanese" => format!("同名のインスタンス属性{name}が存在します"),
|
||||
"simplified_chinese" => format!("同名的实例属性{name}已存在"),
|
||||
"traditional_chinese" => format!("同名的實例屬性{name}已存在"),
|
||||
"english" => format!("an instance attribute named {name} already exists"),
|
||||
),
|
||||
errno,
|
||||
NameWarning,
|
||||
loc,
|
||||
),
|
||||
input,
|
||||
caused_by,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue