From 9de0c725f6608b8eb5d2a7b14a8b787751f48fd7 Mon Sep 17 00:00:00 2001 From: Larpon Date: Wed, 18 May 2022 12:38:58 +0200 Subject: [PATCH] checker: add test for empty #flag node, (fix #14291) (#14447) --- vlib/v/checker/checker.v | 3 +++ vlib/v/parser/tests/hash_empty_flag_value.out | 3 +++ vlib/v/parser/tests/hash_empty_flag_value.vv | 1 + 3 files changed, 7 insertions(+) create mode 100644 vlib/v/parser/tests/hash_empty_flag_value.out create mode 100644 vlib/v/parser/tests/hash_empty_flag_value.vv diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index c2fe0a8694..1173cbeb99 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -2460,6 +2460,9 @@ fn (mut c Checker) hash_stmt(mut node ast.HashStmt) { 'flag' { // #flag linux -lm mut flag := node.main + if flag == 'flag' { // Checks for empty flag + c.error('no argument(s) provided for #flag', node.pos) + } if flag.contains('@VROOT') { // c.note(checker.vroot_is_deprecated_message, node.pos) flag = util.resolve_vmodroot(flag.replace('@VROOT', '@VMODROOT'), c.file.path) or { diff --git a/vlib/v/parser/tests/hash_empty_flag_value.out b/vlib/v/parser/tests/hash_empty_flag_value.out new file mode 100644 index 0000000000..bf815e2698 --- /dev/null +++ b/vlib/v/parser/tests/hash_empty_flag_value.out @@ -0,0 +1,3 @@ +vlib/v/parser/tests/hash_empty_flag_value.vv:1:1: error: no argument(s) provided for #flag + 1 | #flag + | ~~~~~ \ No newline at end of file diff --git a/vlib/v/parser/tests/hash_empty_flag_value.vv b/vlib/v/parser/tests/hash_empty_flag_value.vv new file mode 100644 index 0000000000..461b0afeb2 --- /dev/null +++ b/vlib/v/parser/tests/hash_empty_flag_value.vv @@ -0,0 +1 @@ +#flag