Skip to content

Commit

Permalink
compiler: don't emit duplicate nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurC committed Aug 7, 2024
1 parent 81e5762 commit b086e14
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/hyperfiddle/electric/impl/lang_de2.clj
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@
(::join) (let [e (->id)] (recur (second form) e env (-> (ts/add ts {:db/id e, ::parent pe, ::type ::join})
(?add-source-map e form))))
(::site) (let [[_ site bform] form, current (::current env), env2 (assoc env ::current site)]
(if (or (nil? site) (= site current))
(if (or (nil? site) (= site current) (= ::bindlocal (::type (ts/->node ts pe))))
(let [e (->id)]
(recur bform e env2
(-> (ts/add ts {:db/id e, ::parent pe, ::type ::site, ::site site})
Expand Down
5 changes: 2 additions & 3 deletions test/hyperfiddle/electric/impl/compiler_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,10 @@
(fn [~'frame] (r/pure nil)))])

(match (l/test-compile ::Main (e/pure (e/server 2)))
`[(r/cdef 0 [:server nil] [] nil
`[(r/cdef 0 [:server] [] nil
(fn [~'frame]
(r/define-node ~'frame 0 (r/pure 2))
(r/define-node ~'frame 1 (r/node ~'frame 0))
(r/pure (r/incseq ~'frame (r/node ~'frame 1)))))])
(r/pure (r/incseq ~'frame (r/node ~'frame 0)))))])

(match (l/test-compile ::Main (let [x (e/server (identity 1))] (inc x)))
`[(r/cdef 0 [:server] [] nil
Expand Down

0 comments on commit b086e14

Please sign in to comment.