From 08099b3da8891ee2f8408d8aecb0681b5669f2c8 Mon Sep 17 00:00:00 2001 From: itchyny Date: Sun, 4 Sep 2022 09:30:59 +0900 Subject: [PATCH] Fix path tracking on value arguments --- src/compile/compiler.rs | 6 ++++++ tests/hand_written/mod.rs | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/compile/compiler.rs b/src/compile/compiler.rs index f8d9433..a37a320 100644 --- a/src/compile/compiler.rs +++ b/src/compile/compiler.rs @@ -663,6 +663,9 @@ impl Compiler { .emit_normal_op(ByteCode::PushClosure(closure), next); } ArgType::Value => { + next = self + .emitter + .emit_normal_op(ByteCode::ExitNonPathTracking, next); if require_context { next = self.emitter.emit_normal_op(ByteCode::Swap, next); } @@ -672,6 +675,9 @@ impl Compiler { } else { require_context = true; } + next = self + .emitter + .emit_normal_op(ByteCode::EnterNonPathTracking, next); } } } diff --git a/tests/hand_written/mod.rs b/tests/hand_written/mod.rs index bcffe70..c26b79b 100644 --- a/tests/hand_written/mod.rs +++ b/tests/hand_written/mod.rs @@ -877,3 +877,16 @@ test!( "🤔" "# ); + +test!( + path_value_argument, + r#" + def f($x): .y; path(f(.x)) + "#, + r#" + null + "#, + r#" + ["y"] + "# +);