Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zachcran opened this issue Mar 11, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@zachcran
Copy link
Contributor

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."

@zachcran zachcran added the bug Something isn't working label Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant