hsutter / cppfront

A personal experimental C++ Syntax 2 -> Syntax 1 compiler
Other
5.23k stars 224 forks source link

[BUG] virtual function with multiple return values errors out if no body is defined #1109

Open DyXel opened 2 weeks ago

DyXel commented 2 weeks ago

Describe the bug As title says, I would expect this to work, and you'd later do the full definition (which I guess should reuse the same "inline struct" under the hood?). I understand that multiple return values support is incomplete, and that generally, these kind of functions must have a body, but even the returned error seems unrelated/confusing.

To Reproduce Steps to reproduce the behavior:

  1. Sample code

    my_i: @interface type =
    {
    query_declared_value_set_functions: (this) -> (
            out_this_in_that: bool,
            out_this_move_that: bool,
            inout_this_in_that: bool,
            inout_this_move_that: bool,
        );
    }

    (Note: you don't strictly need the @interface metafunction)

  2. Command lines including which C++ compiler you are using N/A -- happens on every setting.

  3. Expected result - what you expected to happen I'd expect this to simply compile (or give a different error if not technically feasible yet).

  4. Actual result/error Weird error (the function has no body, why is it mentioning initialization):

    test.cpp2(7,13): error: local variable inout_this_move_that is used before it was initialized
    ==> program violates initialization safety guarantee - see previous errors

Additional context Keen eyes may have noticed that the function signature used is part of the current Reflection API, I am currently messing around with it as part of my work on user defined metafunctions. (finally have more time to dedicate to it 😃 )