Fix bug with inline expansion with no arguments

This commit is contained in:
Joshua Suskalo 2021-10-14 13:05:51 -05:00
parent 301f6c1534
commit 9cc83e7d1a
2 changed files with 12 additions and 7 deletions

View file

@ -2,6 +2,8 @@
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
## [Unreleased]
### Fixed
- Incorrect inline expansion of `make-serde-wrapper` in cases where a function has no arguments
## [0.1.241] - 2021-10-14
### Performance

View file

@ -305,10 +305,12 @@
nil))
(list sym `(mem/serialize ~sym ~type ~scope))))
arg-syms arg-types)
wrap-scope (fn [expr]
`(with-open [~scope (mem/stack-scope)]
~expr))
wrap-serialize (fn [expr]
`(with-open [~scope (mem/stack-scope)]
(let [~@(mapcat identity serialize-args)]
~expr)))
`(let [~@(mapcat identity serialize-args)]
~expr))
native-fn (fn [expr]
`(fn ~'native-fn [~@arg-syms]
~expr))
@ -321,6 +323,7 @@
primitive-ret?
(-> (cons downcall-sym arg-syms)
wrap-serialize
wrap-scope
native-fn)
:else
@ -336,12 +339,12 @@
const-ret?)
(native-fn (if (mem/primitive-type ret-type)
prim-call
non-prim-call))
(wrap-scope non-prim-call)))
none-to-serialize?
(if (mem/primitive-type ~ret)
~(native-fn prim-call)
~(native-fn non-prim-call))
`(if (mem/primitive-type ~ret)
~(native-fn prim-call)
~(native-fn (wrap-scope non-prim-call)))
const-ret?
(native-fn (wrap-serialize