Skip to content

Commit 7902ef0

Browse files
committed
bangls gswitch 报错位置修复
1 parent 93c927b commit 7902ef0

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/bangls/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bangls"
3-
version = "0.1.31"
3+
version = "0.1.32"
44
edition = "2024"
55

66
[features]

tools/syntax/src/lib.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3699,10 +3699,12 @@ impl GSwitch {
36993699
Item = usize
37003700
> + '_ {
37013701
let loc = ids.unit();
3702-
let loc = move |meta: &CompileMeta| {
3703-
let (line, column) = loc.location(&meta.source);
3704-
format!("{line}:{column}")
3705-
};
3702+
macro_rules! err1 {
3703+
($f:tt, $($t:tt)*) => {{
3704+
let loc = loc.location(&meta.source);
3705+
err!(loc => $f, format!("{}:{}", loc.0, loc.1), $($t)*);
3706+
}};
3707+
}
37063708

37073709
ids.value.into_taked_args_handle(meta)
37083710
.into_iter()
@@ -3711,19 +3713,19 @@ impl GSwitch {
37113713
.map(|x| match x.0.round() {
37123714
n if n < 0. => {
37133715
meta.log_expand_stack::<true>();
3714-
err!("{} 小于0的gswitch id: {}", loc(meta), n);
3716+
err1!("{} 小于0的gswitch id: {}", n);
37153717
meta.exit(4);
37163718
},
37173719
n if n >= GSwitch::MAX_CONST_ID as f64 => {
37183720
meta.log_expand_stack::<true>();
3719-
err!("{} 过大的gswitch id: {}", loc(meta), n);
3721+
err1!("{} 过大的gswitch id: {}", n);
37203722
meta.exit(4);
37213723
},
37223724
n => n as usize,
37233725
})
37243726
.unwrap_or_else(|| {
37253727
meta.log_expand_stack::<true>();
3726-
err!("{} gswitch id并不是一个数字", loc(meta));
3728+
err1!("{} gswitch id并不是一个数字",);
37273729
meta.exit(4);
37283730
}))
37293731
}

0 commit comments

Comments
 (0)