Add: Location moved to ErrorCore

This commit is contained in:
GreasySlug 2022-11-18 12:31:44 +09:00
parent 000124fea8
commit 4ae81aa05e
6 changed files with 80 additions and 6 deletions

View file

@ -27,6 +27,7 @@ pub fn class_func(mut args: ValueArgs, ctx: &Context) -> EvalValueResult<ValueOb
AtomicStr::from(format!("{REQ_ERR} is not passed")),
line!() as usize,
ErrorKind::TypeError,
Location::Unknown,
)
})?;
let Some(require) = require.as_type() else {
@ -38,6 +39,7 @@ pub fn class_func(mut args: ValueArgs, ctx: &Context) -> EvalValueResult<ValueOb
)),
line!() as usize,
ErrorKind::TypeError,
Location::Unknown,
).into());
};
let impls = args.remove_left_or_key("Impl");
@ -55,6 +57,7 @@ pub fn inherit_func(mut args: ValueArgs, ctx: &Context) -> EvalValueResult<Value
AtomicStr::from(format!("{sup} is not passed")),
line!() as usize,
ErrorKind::KeyError,
Location::Unknown,
)
})?;
let Some(sup) = sup.as_type() else {
@ -66,6 +69,7 @@ pub fn inherit_func(mut args: ValueArgs, ctx: &Context) -> EvalValueResult<Value
)),
line!() as usize,
ErrorKind::TypeError,
Location::Unknown,
).into());
};
let impls = args.remove_left_or_key("Impl");
@ -87,6 +91,7 @@ pub fn inheritable_func(mut args: ValueArgs, _ctx: &Context) -> EvalValueResult<
AtomicStr::from(format!("{CLASS_ERR} is not passed")),
line!() as usize,
ErrorKind::KeyError,
Location::Unknown,
)
})?;
match class {
@ -118,6 +123,7 @@ pub fn trait_func(mut args: ValueArgs, ctx: &Context) -> EvalValueResult<ValueOb
AtomicStr::from(format!("{REQ_ERR} is not passed")),
line!() as usize,
ErrorKind::KeyError,
Location::Unknown,
)
})?;
let Some(require) = require.as_type() else {
@ -129,6 +135,7 @@ pub fn trait_func(mut args: ValueArgs, ctx: &Context) -> EvalValueResult<ValueOb
)),
line!() as usize,
ErrorKind::TypeError,
Location::Unknown,
).into());
};
let impls = args.remove_left_or_key("Impl");
@ -145,6 +152,7 @@ pub fn subsume_func(mut args: ValueArgs, ctx: &Context) -> EvalValueResult<Value
AtomicStr::from(format!("{SUP_ERR} is not passed")),
line!() as usize,
ErrorKind::KeyError,
Location::Unknown,
)
})?;
let Some(sup) = sup.as_type() else {
@ -156,6 +164,7 @@ pub fn subsume_func(mut args: ValueArgs, ctx: &Context) -> EvalValueResult<Value
)),
line!() as usize,
ErrorKind::TypeError,
Location::Unknown,
).into());
};
let impls = args.remove_left_or_key("Impl");
@ -186,6 +195,7 @@ pub fn __array_getitem__(mut args: ValueArgs, ctx: &Context) -> EvalValueResult<
)),
line!() as usize,
ErrorKind::IndexError,
Location::Unknown,
)
.into())
}
@ -219,6 +229,7 @@ pub fn __dict_getitem__(mut args: ValueArgs, ctx: &Context) -> EvalValueResult<V
AtomicStr::from(format!("{slf} has no key {index}",)),
line!() as usize,
ErrorKind::IndexError,
Location::Unknown,
)
.into())
}
@ -243,6 +254,7 @@ pub fn __range_getitem__(mut args: ValueArgs, _ctx: &Context) -> EvalValueResult
AtomicStr::from(format!("Index out of range: {}", index)),
line!() as usize,
ErrorKind::IndexError,
Location::Unknown,
)
.into())
}

View file

@ -771,6 +771,7 @@ impl Context {
e.core.main_message,
e.core.errno,
e.core.kind,
e.core.loc,
);
TyCheckError::new(core, self.cfg.input.clone(), e.caused_by)
})
@ -818,6 +819,7 @@ impl Context {
e.core.main_message,
e.core.errno,
e.core.kind,
e.core.loc,
);
TyCheckError::new(core, self.cfg.input.clone(), e.caused_by)
})

View file

@ -177,6 +177,7 @@ impl CompileError {
),
errno,
CompilerSystemError,
loc,
),
input,
"".into(),
@ -209,6 +210,7 @@ impl CompileError {
),
0,
CompilerSystemError,
loc,
),
input,
"".into(),
@ -227,6 +229,7 @@ impl CompileError {
),
0,
FeatureError,
loc,
),
input,
caused_by,
@ -245,6 +248,7 @@ impl CompileError {
),
0,
SystemExit,
Location::Unknown,
),
Input::Dummy,
"".into(),
@ -285,6 +289,7 @@ impl TyCheckError {
),
errno,
CompilerSystemError,
loc,
),
input,
"".into(),
@ -310,6 +315,7 @@ impl TyCheckError {
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -339,6 +345,7 @@ impl TyCheckError {
),
errno,
NotImplementedError,
callee.loc(),
),
input,
caused_by,
@ -385,6 +392,7 @@ impl TyCheckError {
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -413,6 +421,7 @@ impl TyCheckError {
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -438,6 +447,7 @@ impl TyCheckError {
),
errno,
NameError,
loc,
),
input,
caused_by,
@ -465,6 +475,7 @@ impl TyCheckError {
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -489,6 +500,7 @@ impl TyCheckError {
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -513,6 +525,7 @@ impl TyCheckError {
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -587,6 +600,7 @@ passed keyword args: {kw_args_len}"
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -619,6 +633,7 @@ passed keyword args: {kw_args_len}"
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -646,6 +661,7 @@ passed keyword args: {kw_args_len}"
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -673,6 +689,7 @@ passed keyword args: {kw_args_len}"
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -700,6 +717,7 @@ passed keyword args: {kw_args_len}"
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -727,6 +745,7 @@ passed keyword args: {kw_args_len}"
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -754,6 +773,7 @@ passed keyword args: {kw_args_len}"
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -780,6 +800,7 @@ passed keyword args: {kw_args_len}"
),
errno,
TypeError,
Location::Unknown,
),
input,
caused_by,
@ -805,6 +826,7 @@ passed keyword args: {kw_args_len}"
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -831,6 +853,7 @@ passed keyword args: {kw_args_len}"
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -865,6 +888,7 @@ passed keyword args: {kw_args_len}"
),
errno,
MethodError,
loc,
),
input,
caused_by,
@ -897,6 +921,7 @@ passed keyword args: {kw_args_len}"
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -925,6 +950,7 @@ passed keyword args: {kw_args_len}"
),
errno,
TypeError,
Location::Unknown,
),
input,
caused_by,
@ -953,6 +979,7 @@ passed keyword args: {kw_args_len}"
),
errno,
TypeError,
Location::Unknown,
),
input,
caused_by,
@ -978,6 +1005,7 @@ passed keyword args: {kw_args_len}"
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -1010,6 +1038,7 @@ passed keyword args: {kw_args_len}"
),
errno,
TypeError,
expr.loc(),
),
input,
caused_by,
@ -1041,6 +1070,7 @@ impl EvalError {
),
errno,
NotConstExpr,
loc,
),
input,
caused_by,
@ -1064,6 +1094,7 @@ impl EvalError {
),
errno,
SyntaxError,
loc,
),
input,
caused_by,
@ -1092,6 +1123,7 @@ impl EffectError {
),
errno,
HasEffect,
expr.loc(),
),
input,
caused_by.into(),
@ -1124,6 +1156,7 @@ impl EffectError {
),
errno,
HasEffect,
sig.loc(),
),
input,
caused_by.into(),
@ -1167,6 +1200,7 @@ impl OwnershipError {
),
errno,
MoveError,
name_loc,
),
input,
caused_by.into(),
@ -1196,6 +1230,7 @@ impl LowerError {
desc.into(),
errno,
SyntaxError,
loc,
),
input,
caused_by,
@ -1221,6 +1256,7 @@ impl LowerError {
),
errno,
NameError,
loc,
),
input,
caused_by,
@ -1246,6 +1282,7 @@ impl LowerError {
),
errno,
NameError,
loc,
),
input,
caused_by,
@ -1275,6 +1312,7 @@ impl LowerError {
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -1312,6 +1350,7 @@ impl LowerError {
),
errno,
NameError,
loc,
),
input,
caused_by,
@ -1344,6 +1383,7 @@ impl LowerError {
),
errno,
NameError,
loc,
),
input,
caused_by,
@ -1380,6 +1420,7 @@ impl LowerError {
),
errno,
AttributeError,
loc,
),
input,
caused_by,
@ -1419,6 +1460,7 @@ impl LowerError {
),
errno,
AttributeError,
loc,
),
input,
caused_by,
@ -1444,6 +1486,7 @@ impl LowerError {
),
errno,
AssignError,
loc,
),
input,
caused_by,
@ -1469,6 +1512,7 @@ impl LowerError {
),
errno,
UnusedWarning,
loc,
),
input,
caused_by,
@ -1492,6 +1536,7 @@ impl LowerError {
),
errno,
NameError,
ident.loc(),
),
input,
caused_by,
@ -1534,6 +1579,7 @@ impl LowerError {
),
errno,
VisibilityError,
loc,
),
input,
caused_by,
@ -1580,6 +1626,7 @@ impl LowerError {
),
errno,
NameError,
name_loc,
),
input,
caused_by.into(),
@ -1604,6 +1651,7 @@ impl LowerError {
),
errno,
InheritanceError,
loc,
),
input,
caused_by,
@ -1619,7 +1667,7 @@ impl LowerError {
hint: Option<AtomicStr>,
) -> Self {
Self::new(
ErrorCore::new( vec![SubMessage::ambiguous_new(loc, None, hint)], desc, errno, IoError),
ErrorCore::new( vec![SubMessage::ambiguous_new(loc, None, hint)], desc, errno, IoError, loc),
input,
caused_by,
)
@ -1689,6 +1737,7 @@ impl LowerError {
),
errno,
TypeError,
loc,
),
input,
caused_by,
@ -1707,6 +1756,7 @@ impl LowerError {
),
errno,
SyntaxError,
loc,
),
input,
caused_by,
@ -1740,6 +1790,7 @@ impl LowerError {
),
errno,
TypeError,
loc,
),
input,
caused_by,

View file

@ -44,6 +44,7 @@ impl From<DeserializeError> for ErrorCore {
err.desc,
err.errno,
ErrorKind::ImportError,
Location::Unknown,
)
}
}