Thanks to visit codestin.com
Credit goes to github.com

Skip to content

NullPointerException #72

@pesterhazy

Description

@pesterhazy

With latest 0.4.12, the following code crashes zprint (graalvm-compiled):

#?(:clj
   (defmacro deftrecord
     "Augment all datascript.parser/ records with default implementation of ITraversable"
     [tagname fields & rest]
     (let [f    (gensym "f")
           pred (gensym "pred")
           acc  (gensym "acc")]
       `(defrecord ~tagname ~fields
          ITraversable
          (~'-postwalk [this# ~f]
           (let [new# (new ~tagname ~@(map #(list 'datascript.parser/postwalk % f) fields))]
             (if-let [meta# (meta this#)]
               (with-meta new# meta#)
               new#)))
          (~'-collect [_# ~pred ~acc]
           ;; [x y z] -> (collect pred z (collect pred y (collect pred x acc)))
           ~(reduce #(list 'datascript.parser/collect pred %2 %1) acc fields))
          (~'-collect-vars [_# ~acc]
           ;; [x y z] -> (collect-vars-acc (collect-vars-acc (collect-vars-acc acc x) y) z)
           ~(reduce #(list 'datascript.parser/collect-vars-acc %1 %2) acc fields))
          ~@rest))))

Taken from https://github.com/tonsky/datascript/blob/25f6c1afdc60004bd5936fec917139eac59fa3b1/src/datascript/parser.cljc - I tried to minimize the repro.

For background, I tried to reformat all the files collected in https://github.com/pesterhazy/cljs-spa-example. The good news is that almost all of them work fine! This is not urgent at all but I thought I might file a report.

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