Skip to content

Commit 9642f24

Browse files
ENT-13826: Error on user-defined bundle/body with the name of a built-in func
Signed-off-by: Simon Halvorsen <simon.halvorsen@northern.tech>
1 parent d4eb010 commit 9642f24

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/cfengine_cli/lint.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,15 @@ def _lint_node(node: Node, policy_file: PolicyFile, state: State) -> int:
492492
f"Error: Bundle type must be one of ({', '.join(ALLOWED_BUNDLE_TYPES)}), not '{_text(node)}' {location}"
493493
)
494494
return 1
495+
if state.strict and (
496+
node.type in ("bundle_block_name", "body_block_name")
497+
and _text(node) in BUILTIN_FUNCTIONS
498+
):
499+
_highlight_range(node, lines)
500+
print(
501+
f"Error: {"Bundle" if "bundle" in node.type else "Body"} '{_text(node)}' shadows built-in function with the same name {location}"
502+
)
503+
return 1
495504
if node.type == "calling_identifier":
496505
name = _text(node)
497506
qualified_name = _qualify(name, state.namespace)

0 commit comments

Comments
 (0)