Skip to content

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

@phronmophobic

Description

@phronmophobic

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions