diff --git a/examples/basic_nesting/src/data/demo/functions/foo.mcfunction b/examples/basic_nesting/src/data/demo/functions/foo.mcfunction index 13d5f39..f63ea70 100644 --- a/examples/basic_nesting/src/data/demo/functions/foo.mcfunction +++ b/examples/basic_nesting/src/data/demo/functions/foo.mcfunction @@ -192,3 +192,13 @@ function demo:blob: append function demo:blob: say aaaaa say after + +function demo:ret1: + execute if score some score matches 0 run return run execute run function demo:ret1/cond: + say hi + return 0 + +function demo:ret2: + execute if score some score matches 0 run return run function demo:ret2/cond: + say hi + return 0 diff --git a/mecha/contrib/nesting.py b/mecha/contrib/nesting.py index 67dd58c..3e15026 100644 --- a/mecha/contrib/nesting.py +++ b/mecha/contrib/nesting.py @@ -146,7 +146,8 @@ def nesting_execute_run(self, node: AstCommand): return node @rule(AstCommand, identifier="execute:run:subcommand") - def nesting_execute_function(self, node: AstCommand): + @rule(AstCommand, identifier="return:run:subcommand") + def nesting_run_function(self, node: AstCommand): if isinstance(command := node.arguments[0], AstCommand): if command.identifier in self.identifier_map: yield from self.handle_function(command) diff --git a/tests/snapshots/examples__build_basic_nesting__0.pack.md b/tests/snapshots/examples__build_basic_nesting__0.pack.md index f1c26be..9f95c2f 100644 --- a/tests/snapshots/examples__build_basic_nesting__0.pack.md +++ b/tests/snapshots/examples__build_basic_nesting__0.pack.md @@ -253,6 +253,20 @@ say anonymous definition 7 say anonymous definition 8 ``` +`@function demo:ret1/cond` + +```mcfunction +say hi +return 0 +``` + +`@function demo:ret2/cond` + +```mcfunction +say hi +return 0 +``` + `@function demo:thing1` ```mcfunction @@ -290,6 +304,18 @@ say aaaaa say after ``` +`@function demo:ret1` + +```mcfunction +execute if score some score matches 0 run return run function demo:ret1/cond +``` + +`@function demo:ret2` + +```mcfunction +execute if score some score matches 0 run return run function demo:ret2/cond +``` + `@function demo:wat/nested_execute_0` ```mcfunction