Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structs with pointer array field throws exception in dt-struct/define-datatype! #114

Open
phronmophobic opened this issue Sep 24, 2024 · 0 comments

Comments

@phronmophobic
Copy link
Contributor

dt-struct/define-datatype! will throw an Exception if any of the fields has :datatype :pointer and :n-elems is greater than one.

Below is a minimal repro:

> (dt-struct/define-datatype! ::HasPointerArray
  [{:n-elems 10, :datatype :pointer, :name :ptrs}])
Execution error (AssertionError) at tech.v3.datatype.struct/create-accessors$fn (struct.clj:332).
Assert failed: Datatype :pointer created invalid acccessr
(and (instance? IFn$OOLO read-fn) (instance? IFn$OOLOO write-fn))
> (prn *e)
#error {
 :cause "Assert failed: Datatype :pointer created invalid acccessr\n(and (instance? IFn$OOLO read-fn) (instance? IFn$OOLOO write-fn))"
 :trace
 [[tech.v3.datatype.struct$create_accessors$fn__16140 invoke "struct.clj" 332]
  [clojure.lang.PersistentVector reduce "PersistentVector.java" 418]
  [clojure.core$reduce invokeStatic "core.clj" 6964]
  [clojure.core$reduce invoke "core.clj" 6947]
  [tech.v3.datatype.struct$create_accessors invokeStatic "struct.clj" 226]
  [tech.v3.datatype.struct$create_accessors invoke "struct.clj" 222]
  [tech.v3.datatype.struct$define_datatype_BANG_ invokeStatic "struct.clj" 369]
  [tech.v3.datatype.struct$define_datatype_BANG_ invoke "struct.clj" 347]
  ...]}
nil

Workaround:
Using :int64 instead of :pointer is a sufficient workaround for my use case. I don't actually need to access the pointer array field on this struct for my use case anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant