Skip to content

vmod function/method name clash #3833

@nigoroll

Description

@nigoroll

As demonstrated with this patch

diff --git a/vmod/vmod_debug.vcc b/vmod/vmod_debug.vcc
index df8ba6247..310a046bb 100644
--- a/vmod/vmod_debug.vcc
+++ b/vmod/vmod_debug.vcc
@@ -69,6 +69,8 @@ $Function STRING test_priv_top(PRIV_TOP, STRING)
 
 Test function for TOP private pointers
 
+$Function VOID obj_enum(ENUM { phk, des, kristian, mithrandir, martin })
+
 $Object obj(STRING string="default", ENUM { one, two, three } number=one)
 
 Test object

we do not support a function called obj.name with a method name for class obj.

Compiler error:

/usr/local/bin/python3.10 ../lib/libvcc/vmodtool.py --boilerplate -o vcc_debug_if ./vmod_debug.vcc
WARNING: Not emitting .RST for $Event event_function

WARNING: Not emitting .RST for $Event event_function

  CC       libvmod_debug_la-vcc_debug_if.lo
In file included from vcc_debug_if.c:10:
./vcc_debug_if.h:94:10: error: conflicting types for 'xyzzy_obj_enum'
VCL_VOID xyzzy_obj_enum(VRT_CTX, struct VPFX(debug_obj) *,
         ^
./vcc_debug_if.h:89:10: note: previous declaration is here
VCL_VOID xyzzy_obj_enum(VRT_CTX, VCL_ENUM);
         ^
vcc_debug_if.c:128:18: error: typedef redefinition with different types ('VCL_VOID (const struct vrt_ctx *, VCL_ENUM)' (aka 'void (const struct vrt_ctx *, const char *)') vs 'VCL_VOID (const struct vrt_ctx *, struct xyzzy_debug_obj *, VCL_ENUM)' (aka 'void (const struct vrt_ctx *, struct xyzzy_debug_obj *, const char *)'))
typedef VCL_VOID td_xyzzy_debug_obj_enum(VRT_CTX, VCL_ENUM);
                 ^
vcc_debug_if.c:32:18: note: previous definition is here
typedef VCL_VOID td_xyzzy_debug_obj_enum(VRT_CTX,
                 ^
vcc_debug_if.c:201:28: error: duplicate member 'obj_enum'
        td_xyzzy_debug_obj_enum         *obj_enum;
                                         ^
vcc_debug_if.c:198:28: note: previous declaration is here
        td_xyzzy_debug_obj_enum         *obj_enum;
                                         ^
3 errors generated.
make: *** [Makefile:1154: libvmod_debug_la-vcc_debug_if.lo] Error 1

suggestion: rename methods to obj__method (two underscores) and blacklist underscore as prefix/suffix for object/method/function names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions