jakt
jakt copied to clipboard
Array creation in functions that can't throw errors generates invalid cpp
When allocating arrays in functions that don't return an error type, the compiler generates incorrect cpp code as it uses the TRY
macro.
It might also be nice to annotate that the main function returns and ErrorOr<T>
as that is not clear from the current syntax. In the example below, it looks like the two functions both return void but in main, the array allocation generates correct code while in test if does not.
Example:
function test() {
let mutable data = [0u32; 256]
}
function main() {
test()
}
Arguable this is a typechecker bug more that a codegen one, as the compiler should point out that a fallible operation (array creation) inside a function no marked throws
is not permitted unless explicitly ignored (made "infallible", a.k.a crashing).
See #153
fixed as of d73ef3e
there is now an error message "Array initialization inside non-throwing scope"