june icon indicating copy to clipboard operation
june copied to clipboard

Function call in array index generates uncompilable C code for the backend

Open lefticus opened this issue 11 months ago • 0 comments

fun get_val() -> i64 {
  return 1;
}

let data = raw[1,2,3]
unsafe {
  // note that a literal here, or an explicitly typed
  // index do work in this case.
  data[get_val()]
}

error:

/home/jason/june/examples/june_hello_world/build/debug/main.c:395:71: error: too few arguments to function call, single argument 'allocation_id' was not specified
(*((/* data */ variable_2) + (/* get_val */ function_1(/* UNKNOWN, */ ))));
                                            ~~~~~~~~~~                ^
/home/jason/june/examples/june_hello_world/build/debug/main.c:387:23: note: 'function_1' declared here
int64_t /* get_val */ function_1(long allocation_id){
                      ^
1 error generated.
thread 'main' panicked at src/main.rs:90:17:
Clang did not compile successfully
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

See related issue #43 and #41

lefticus avatar Mar 10 '24 00:03 lefticus