From 16574df99b27978f6ec5b4e334b31e8d0949fec7 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Fri, 9 Feb 2024 21:02:43 -0300 Subject: [PATCH] ast: fix global const ordering with string inter literal (fix #20760) (#20770) --- vlib/v/ast/table.v | 5 +++++ vlib/v/tests/const_order_with_str_interp_test.v | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 vlib/v/tests/const_order_with_str_interp_test.v diff --git a/vlib/v/ast/table.v b/vlib/v/ast/table.v index a635955960e391..15ca770adc8d3c 100644 --- a/vlib/v/ast/table.v +++ b/vlib/v/ast/table.v @@ -2418,6 +2418,11 @@ pub fn (t &Table) dependent_names_in_expr(expr Expr) []string { PrefixExpr { names << t.dependent_names_in_expr(expr.right) } + StringInterLiteral { + for inter_expr in expr.exprs { + names << t.dependent_names_in_expr(inter_expr) + } + } SelectorExpr { names << t.dependent_names_in_expr(expr.expr) } diff --git a/vlib/v/tests/const_order_with_str_interp_test.v b/vlib/v/tests/const_order_with_str_interp_test.v new file mode 100644 index 00000000000000..7e069b3c9f77b0 --- /dev/null +++ b/vlib/v/tests/const_order_with_str_interp_test.v @@ -0,0 +1,9 @@ +import os + +const exe_path = os.executable() +const exe_old_path = '${exe_path}.old' + +fn test_main() { + assert exe_path == os.executable() + assert exe_old_path == '${os.executable()}.old' +}