-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
I have a simple two class hierarchy, Foo which derives from Bar. In Bar I define a method to_str meant to print Bar. In Foo I try to override to_str so that it first calls Bar::to_str then prints Foo's additional state; instead I get infinite recursion.
To Reproduce
MWE:
cpp_class(Bar)
cpp_constructor(CTOR Bar str)
function("${CTOR}" self _ctor_value)
Bar(SET "${self}" _value "${_ctor_value}")
endfunction()
cpp_member(to_str Bar desc)
function("${to_str}" self _ts_result)
Bar(GET "${self}" _ts_value "_value")
set("${_ts_result}" "Value = ${_ts_value}" PARENT_SCOPE)
endfunction()
cpp_attr(Bar _value)
cpp_end_class()
cpp_class(Foo Bar)
cpp_constructor(CTOR Foo str)
function("${CTOR}" self _ctor_value)
# Related, is possible to call the base ctor?
Foo(SET "${self}" _other_value "${_ctor_value}")
endfunction()
cpp_member(to_str Foo desc)
function("${to_str}" self _ts_result)
Bar(to_str "${self}" _ts_base)
Foo(GET "${self}" _ts_value "_other_value")
set(
"${_ts_result}"
"${_ts_base}\nOther Value = ${_ts_value}"
PARENT_SCOPE
)
endfunction()
cpp_attr(Foo _other_value)
cpp_end_class()
Bar(CTOR my_bar "hello")
Bar(to_str "${my_bar}" as_a_string)
message("${as_a_string}") # Prints "Value = hello"
Foo(CTOR my_foo "world")
Foo(to_str "${my_foo}" as_a_string)
message("${as_a_string}") #Crashes hereExpected behavior
I would expect the code to print "Value = \nOther Value = world"
Additional context
N/A
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working