update: invalid convert error

This commit is contained in:
GreasySlug 2023-01-14 16:06:51 +09:00
parent d1dc1e60e7
commit 1e072835c3
2 changed files with 75 additions and 12 deletions

View file

@ -67,9 +67,14 @@ impl Parser {
Ok(sig)
}
other => {
debug_exit_info!(self);
let err = ParseError::simple_syntax_error(line!() as usize, other.loc());
let err = ParseError::invalid_convert_error(
line!() as usize,
other.loc(),
"rhs",
"signature",
);
self.errs.push(err);
debug_exit_info!(self);
Err(())
}
}
@ -88,7 +93,12 @@ impl Parser {
Ok(VarSignature::new(pat, None))
}
other => {
let err = ParseError::simple_syntax_error(line!() as usize, other.loc());
let err = ParseError::invalid_convert_error(
line!() as usize,
other.loc(),
"accessor",
"variable signature",
);
self.errs.push(err);
debug_exit_info!(self);
Err(())
@ -110,7 +120,12 @@ impl Parser {
vars.push(v);
}
Signature::Subr(subr) => {
let err = ParseError::simple_syntax_error(line!() as usize, subr.loc());
let err = ParseError::invalid_convert_error(
line!() as usize,
subr.loc(),
"array",
"array pattern",
);
self.errs.push(err);
debug_exit_info!(self);
return Err(());
@ -221,8 +236,12 @@ impl Parser {
vars.push(var);
}
other => {
let err =
ParseError::simple_syntax_error(line!() as usize, other.loc());
let err = ParseError::invalid_convert_error(
line!() as usize,
other.loc(),
"Tuple",
"Tuple pattern",
);
self.errs.push(err);
debug_exit_info!(self);
return Err(());
@ -268,7 +287,12 @@ impl Parser {
.convert_accessor_to_ident(acc)
.map_err(|_| self.stack_dec(fn_name!()))?,
other => {
let err = ParseError::simple_syntax_error(line!() as usize, other.loc());
let err = ParseError::invalid_convert_error(
line!() as usize,
other.loc(),
"call",
"subroutine signature",
);
self.errs.push(err);
debug_exit_info!(self);
return Err(());
@ -305,7 +329,12 @@ impl Parser {
(ident, bounds)
}
other => {
let err = ParseError::simple_syntax_error(line!() as usize, other.loc());
let err = ParseError::invalid_convert_error(
line!() as usize,
other.loc(),
"accessor",
"indemnifier",
);
self.errs.push(err);
debug_exit_info!(self);
return Err(());
@ -356,7 +385,12 @@ impl Parser {
Ok(bound)
}
other => {
let err = ParseError::simple_syntax_error(line!() as usize, other.loc());
let err = ParseError::invalid_convert_error(
line!() as usize,
other.loc(),
"type argument",
"bound",
);
self.errs.push(err);
Err(())
}
@ -499,7 +533,12 @@ impl Parser {
}
},
other => {
let err = ParseError::simple_syntax_error(line!() as usize, other.loc());
let err = ParseError::invalid_convert_error(
line!() as usize,
other.loc(),
"right hand side",
"parameter",
);
self.errs.push(err);
debug_exit_info!(self);
Err(())
@ -712,7 +751,12 @@ impl Parser {
}
},
other => {
let err = ParseError::simple_syntax_error(line!() as usize, other.loc());
let err = ParseError::invalid_convert_error(
line!() as usize,
other.loc(),
"right hand side",
"lambda signature",
);
self.errs.push(err);
debug_exit_info!(self);
Err(())
@ -736,7 +780,12 @@ impl Parser {
Ok(NonDefaultParamSignature::new(pat, None))
}
other => {
let err = ParseError::simple_syntax_error(line!() as usize, other.loc());
let err = ParseError::invalid_convert_error(
line!() as usize,
other.loc(),
"accessor",
"parameter signature",
);
self.errs.push(err);
debug_exit_info!(self);
Err(())

View file

@ -164,6 +164,20 @@ impl LexError {
))
}
pub fn invalid_convert_error(errno: usize, loc: Location, from: &str, to: &str) -> ParseError {
Self::syntax_error(
errno,
loc,
switch_lang!(
"japanese" => format!("{}から{}に変換するのに失敗しました", from, to),
"simplified_chinese" => format!("无法将{}转换为{}", from, to),
"traditional_chinese" => format!("無法將{}轉換為{}", from, to),
"english" => format!("failed to convert {} to {}",from, to),
),
None,
)
}
pub fn no_var_error(
errno: usize,
loc: Location,