mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 12:24:45 +00:00
let errors more readable
This commit is contained in:
parent
ba13cf25c8
commit
d7ffb211a8
2 changed files with 7 additions and 6 deletions
|
@ -256,13 +256,14 @@ impl Context {
|
||||||
let constraint = fv.crack_constraint();
|
let constraint = fv.crack_constraint();
|
||||||
let (sub_t, super_t) = constraint.get_sub_sup().unwrap();
|
let (sub_t, super_t) = constraint.get_sub_sup().unwrap();
|
||||||
if self.level <= fv.level().unwrap() {
|
if self.level <= fv.level().unwrap() {
|
||||||
|
// REVIEW: Even if type constraints can be satisfied, implementation may not exist
|
||||||
if self.subtype_of(sub_t, super_t) {
|
if self.subtype_of(sub_t, super_t) {
|
||||||
Ok(sub_t.clone())
|
Ok(sub_t.clone())
|
||||||
} else {
|
} else {
|
||||||
Err(TyCheckError::subtyping_error(
|
Err(TyCheckError::subtyping_error(
|
||||||
line!() as usize,
|
line!() as usize,
|
||||||
sub_t,
|
&self.resolve_tyvar(sub_t.clone(), loc)?,
|
||||||
super_t,
|
&self.resolve_tyvar(super_t.clone(), loc)?,
|
||||||
None,
|
None,
|
||||||
Some(loc),
|
Some(loc),
|
||||||
self.caused_by(),
|
self.caused_by(),
|
||||||
|
|
|
@ -934,10 +934,10 @@ passed keyword args: {RED}{kw_args_len}{RESET}"
|
||||||
TypeError,
|
TypeError,
|
||||||
loc,
|
loc,
|
||||||
switch_lang!(
|
switch_lang!(
|
||||||
"japanese" => format!("部分型制約を満たせません:\nサブタイプ: {YELLOW}{sub_t}{RESET}\nスーパータイプ: {YELLOW}{sup_t}{RESET}"),
|
"japanese" => format!("この式の部分型制約を満たせません:\nサブタイプ: {YELLOW}{sub_t}{RESET}\nスーパータイプ: {YELLOW}{sup_t}{RESET}"),
|
||||||
"simplified_chinese" => format!("无法满足子类型约束:\n子类型:{YELLOW}{sub_t}{RESET}\n超类型:{YELLOW}{sup_t}{RESET}"),
|
"simplified_chinese" => format!("无法满足此表达式中的子类型约束:\n子类型:{YELLOW}{sub_t}{RESET}\n超类型:{YELLOW}{sup_t}{RESET}"),
|
||||||
"traditional_chinese" => format!("無法滿足子類型約束:\n子類型:{YELLOW}{sub_t}{RESET}\n超類型:{YELLOW}{sup_t}{RESET}"),
|
"traditional_chinese" => format!("無法滿足此表達式中的子類型約束:\n子類型:{YELLOW}{sub_t}{RESET}\n超類型:{YELLOW}{sup_t}{RESET}"),
|
||||||
"english" => format!("subtype constraints cannot be satisfied:\nsubtype: {YELLOW}{sub_t}{RESET}\nsupertype: {YELLOW}{sup_t}{RESET}"),
|
"english" => format!("the subtype constraint in this expression cannot be satisfied:\nsubtype: {YELLOW}{sub_t}{RESET}\nsupertype: {YELLOW}{sup_t}{RESET}"),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue