mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 20:34:44 +00:00
Change UnusedError to Warning
This commit is contained in:
parent
302d020245
commit
1f33e3b642
3 changed files with 46 additions and 34 deletions
|
@ -18,7 +18,7 @@ use erg_parser::error::{ParserRunnerError, ParserRunnerErrors};
|
|||
|
||||
use crate::context::Context;
|
||||
use crate::hir::{Expr, Identifier, Signature};
|
||||
use crate::ty::{Predicate, Type};
|
||||
use crate::ty::{HasType, Predicate, Type};
|
||||
|
||||
pub fn ordinal_num(n: usize) -> String {
|
||||
match n.to_string().chars().last().unwrap() {
|
||||
|
@ -109,7 +109,7 @@ pub fn readable_name(name: &str) -> &str {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CompileError {
|
||||
pub core: Box<ErrorCore>, // ErrorCore is large, so box it
|
||||
pub input: Input,
|
||||
|
@ -1458,6 +1458,33 @@ impl LowerError {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn unused_expr_warning(input: Input, errno: usize, expr: &Expr, caused_by: String) -> Self {
|
||||
let desc = switch_lang!(
|
||||
"japanese" => format!("式の評価結果(: {})が使われていません", expr.ref_t()),
|
||||
"simplified_chinese" => format!("表达式评估结果(: {})未使用", expr.ref_t()),
|
||||
"traditional_chinese" => format!("表達式評估結果(: {})未使用", expr.ref_t()),
|
||||
"english" => format!("the evaluation result of the expression (: {}) is not used", expr.ref_t()),
|
||||
);
|
||||
let hint = switch_lang!(
|
||||
"japanese" => "値を使わない場合は、discard関数を使用してください",
|
||||
"simplified_chinese" => "如果您不想使用该值,请使用discard函数",
|
||||
"traditional_chinese" => "如果您不想使用該值,請使用discard函數",
|
||||
"english" => "if you don't use the value, use discard function",
|
||||
)
|
||||
.to_owned();
|
||||
Self::new(
|
||||
ErrorCore::new(
|
||||
vec![SubMessage::ambiguous_new(expr.loc(), vec![], Some(hint))],
|
||||
desc,
|
||||
errno,
|
||||
UnusedWarning,
|
||||
expr.loc(),
|
||||
),
|
||||
input,
|
||||
caused_by,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn duplicate_decl_error(
|
||||
input: Input,
|
||||
errno: usize,
|
||||
|
@ -2234,7 +2261,7 @@ impl LowerError {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CompileErrors(Vec<CompileError>);
|
||||
|
||||
impl std::error::Error for CompileErrors {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue