From af56719f9d7507aa1348b73b0f0741b987fb4b91 Mon Sep 17 00:00:00 2001 From: shove Date: Fri, 28 Oct 2022 11:48:09 +0800 Subject: [PATCH] fmt: fix compiler_error('...') broken by fmt (fix #16218) (#16231) --- vlib/v/fmt/fmt.v | 2 ++ vlib/v/fmt/tests/comptime_method_args_expected.vv | 3 +++ vlib/v/fmt/tests/comptime_method_args_input.vv | 3 +++ 3 files changed, 8 insertions(+) create mode 100644 vlib/v/fmt/tests/comptime_method_args_expected.vv create mode 100644 vlib/v/fmt/tests/comptime_method_args_input.vv diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 1240281f97..b520739d5a 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1868,6 +1868,8 @@ pub fn (mut f Fmt) comptime_call(node ast.ComptimeCall) { f.write("\$env('$node.args_var')") } else if node.is_pkgconfig { f.write("\$pkgconfig('$node.args_var')") + } else if node.method_name == 'compile_error' { + f.write("\$compile_error('$node.args_var')") } else { inner_args := if node.args_var != '' { node.args_var diff --git a/vlib/v/fmt/tests/comptime_method_args_expected.vv b/vlib/v/fmt/tests/comptime_method_args_expected.vv new file mode 100644 index 0000000000..86d24f1cbc --- /dev/null +++ b/vlib/v/fmt/tests/comptime_method_args_expected.vv @@ -0,0 +1,3 @@ +$if !linux { + $compile_error('Only Lin\"ux is currently supported') +} diff --git a/vlib/v/fmt/tests/comptime_method_args_input.vv b/vlib/v/fmt/tests/comptime_method_args_input.vv new file mode 100644 index 0000000000..d4177f6d15 --- /dev/null +++ b/vlib/v/fmt/tests/comptime_method_args_input.vv @@ -0,0 +1,3 @@ +$if !linux { + $compile_error("Only Lin\"ux is currently supported") +}