Skip to content

Commit

Permalink
修复const-match中运行守卫会破坏外部参数
Browse files Browse the repository at this point in the history
  • Loading branch information
A4-Tacks committed Jan 31, 2025
1 parent 5c625c1 commit 9471c51
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mindustry_logic_bang_lang"
version = "0.17.23"
version = "0.17.24"
edition = "2021"

authors = ["A4-Tacks <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion tools/parser/tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "parser-tests"
version = "0.1.48"
version = "0.1.49"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
12 changes: 12 additions & 0 deletions tools/parser/tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6076,6 +6076,18 @@ fn const_match_test() {
"end",
],
);

// 测试守卫作用域
assert_eq!(
CompileMeta::new().compile(parse!(parser, r#"
const match 1 { [?_0 == 1] { x; } _ { y; }}
print _0 @;
"#).unwrap()).compile().unwrap(),
vec![
"x",
"print _0",
],
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion tools/syntax/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "syntax"
version = "0.2.52"
version = "0.2.53"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion tools/syntax/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3304,7 +3304,7 @@ impl ConstMatchPatAtom {
},
Either::Right(guard) => {
let mut res = false;
meta.with_block(|meta| {
meta.with_block_and_env_args(|meta| {
LogicLine::SetArgs([handle.into()].into())
.compile(meta);
res = guard.take_handle(meta).ne("0")
Expand Down

0 comments on commit 9471c51

Please sign in to comment.