CMakePP / CMakePPLang

Object-oriented extension to the CMake language.
http://cmakepp.github.io/CMakePPLang/
Apache License 2.0
11 stars 4 forks source link

Constructor call with blank string argument goes to incorrect constructor #45

Open zachcran opened 2 years ago

zachcran commented 2 years ago

Describe the bug When I have a class with a constructor with the following constructor signature cpp_constructor(CTOR ExampleClass str) and try to instantiate it using a blank string for the string argument, like ExampleClass(CTOR my_class ""), the constructor call is redirected to the automatically generated, default constructor with the signature cpp_constructor(CTOR ExampleClass) taking no arguments.

To Reproduce Minimal example:

include_guard()
include(cmakepp_lang/cmakepp_lang)

cpp_class(ExampleClass)
    cpp_constructor(CTOR ExampleClass)
    function("${CTOR}" self)
        message("The call reached the default constructor with no arguments.")
    endfunction()

    cpp_constructor(CTOR ExampleClass str)
    function("${CTOR}" self arg1)
        message("The call reached the expected constructor with an argument.")
    endfunction()
cpp_end_class()

ExampleClass(CTOR my_class "")

# Output: The call reached the default constructor with no arguments.

Expected behavior From a discussion with @ryanmrichard, "CMake functions create a list out of all of the arguments; so your input should have become: CTOR;toolchain_obj;. Without the "" it would be CTOR;toolchain_obj (no trailing semicolon), so the two should be distinguishable."