jakt
jakt copied to clipboard
yield by itself generates invalid cpp
For example:
function foo() {
yield 1;
}
function main() {
foo();
}
Generates:
#include <lib.h>
static void foo();
static void foo()
{
using _JaktCurrentFunctionReturnType = void;
({ Optional<i64> __jakt_var_0; {
__jakt_var_0 = static_cast<i64>(1LL); goto __jakt_label_0;
}
__jakt_label_0:; __jakt_var_0.release_value(); })}
ErrorOr<int> JaktMain::main(Array<String>)
{
using _JaktCurrentFunctionReturnType = ErrorOr<int>;
{
foo();
}
return 0;
}
Which produces this:
/home/lukew/Desktop/repos/jakt/build/a.cpp:11:50: error: expected ';' after expression
__jakt_label_0:; __jakt_var_0.release_value(); })}
^
;
/home/lukew/Desktop/repos/jakt/build/a.cpp:11:18: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
__jakt_label_0:; __jakt_var_0.release_value(); })}
^~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 1 error generated.