cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

[BUG] cpp2::deferred_init does not accept initialisation by external function

Open filipsajdak opened this issue 2 years ago • 0 comments

The local variables can be initialized by external functions that take out argument. cpp2::deferred_init treat it as violation of initialization safety and reports error:

error: local variable i is used before it was initialized
fun: () -> (i:int) = {
    init(i);
    return;
}

init: (out i : int) = {
    i = 42;
}

After trying to compile that with cppfront we got:

cppfront % build/external/cppfront external/tests/defered.cpp2
external/tests/defered.cpp2...
defered.cpp2(2,10): error: local variable i is used before it was initialized
  ==> program violates initialization safety guarantee - see previous errors

I expect cppfront accepts the functions that have out argument as proper initialization of deferred_init variables (assuming that there is a check that out argument, inside the function, has an assignment operation done on it).

filipsajdak avatar Oct 09 '22 09:10 filipsajdak