Skip to content

Type information on cpp/unbox mismatch errors when using aliases and/or * without spaces #593

@mauricioszabo

Description

@mauricioszabo

jank health check

─ system ───────────────────────────────────────────────────────────────────────────────────────────
─ ✅ operating system: linux
─ ✅ default triple: x86_64-unknown-linux-gnu

─ jank install ─────────────────────────────────────────────────────────────────────────────────────
─ ✅ jank version: jank-0.1-6ebd32966e07133861a5734e892a5cfc02bca024
─ ✅ jank resource dir: ../lib/jank/0.1
─ ✅ jank resolved resource dir: /usr/local/bin/../lib/jank/0.1 (found)
─ ✅ jank user cache dir: /home/mauricio/.cache/jank/x86_64-unknown-linux-gnu-8ef9488056101afe1d0969786e5dc264017e65e64f3b420fe6ba9d169dbf29e9 (found)

─ clang install ────────────────────────────────────────────────────────────────────────────────────
─ ⚠ configured clang path: /home/runner/work/jank/jank/compiler+runtime/build/llvm-install/usr/local/bin/clang++ (not found)
─ ✅ runtime clang path: /usr/local/bin/../lib/jank/0.1/bin/clang++ (found)
─ ⚠ configured clang resource dir: /home/runner/work/jank/jank/compiler+runtime/build/llvm-install/usr/local/lib/clang/22 (not found)
─ ✅ runtime clang resource dir: /usr/local/lib/jank/0.1/lib/clang/22 (found)

─ jank runtime ─────────────────────────────────────────────────────────────────────────────────────
─ ✅ jank runtime initialized
─ ✅ jank pch path: /home/mauricio/.cache/jank/x86_64-unknown-linux-gnu-8ef9488056101afe1d0969786e5dc264017e65e64f3b420fe6ba9d169dbf29e9 (found)
─ ✅ jank can jit compile c++
─ ✅ jank can jit compile llvm ir
─ ✅ jank can aot compile working binaries

Description of the issue with reproduction steps

Given the following code:

(ns types)

(cpp/raw "
#ifndef DUP_CODE
#define DUP_CODE

#include <jank/c_api.h>

typedef uintptr_t VALUE;

static VALUE something = 10;
static void a_function(VALUE a_value) {
}

static void interop() {
  auto boxed_value1 = jank_box(\"VALUE *\", (void *) &something);
  auto boxed_value2 = jank_box(\"unsigned long *\", (void *) &something);
  auto boxed_value3 = jank_box(\"unsigned long*\", (void *) &something);
  auto const the_function(jank_var_intern_c(\"types\", \"a-function\"));
  jank_call3(jank_deref(the_function), boxed_value1, boxed_value2, boxed_value3);
}

#endif
 ")

(defn a-function [boxed1 boxed2 boxed3]
  (let [unboxed (cpp/* (cpp/unbox cpp/VALUE* boxed2))]
    (cpp/a_function unboxed)))

(defn -main [ & args]
  (cpp/interop))

At the line (let [unboxed (cpp/* (cpp/unbox cpp/VALUE* boxed2))], it'll only work when I am using the boxed2 version. Using boxed1 will crash with This opaque box holds a 'VALUE *', but it was unboxed as a 'unsigned long *'; using boxed3 will crash with error: This opaque box holds a 'unsigned long*', but it was unboxed as a 'unsigned long *'.

Stack trace

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    category:runtimeActual Clojure code, core libs, and all the C++ code in `jank::runtime`.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions