-
Notifications
You must be signed in to change notification settings - Fork 128
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
Don't allow prerequisite values for inlined functions #60
Comments
Would this be adding to |
So something like this?: ;; tst
(defn doubler [n] (+ n n))
(after-silently
(expect (doubler 3) => 0
(fake (+ 3 3) => 0))
(expect @reported => (user-error-with-notes #"cannot fake the function")))
;; src
(defn- compiler-will-inline-fn? [[fn & args :as funcall]]
(contains? (meta (var fn)) :inline))
(defmethod validate "fake" [[_fake_ & fake-form :as form]]
(let [funcall (first fake-form)]
(cond (not (list? funcall))
(user-error-report-form
form
"The left-hand-side of a prerequisite must look like a function call."
(cl-format nil "`~S` doesn't." funcall))
(compiler-will-inline-fn? funcall)
(user-error-report-form
form
(cl-format nil "You cannot fake the function `~S` because it is inlined by the Clojure compiler." (first funcall)))
:else
fake-form))) |
That seems a reasonable way to do it. Are you going to? Otherwise I will. (I wouldn't use "fake" in the error message, since that's not a word midje.sweet exposes. Perhaps "you cannot override a call to On Nov 5, 2011, at 8:08 PM, AlexBaranosky wrote:
Brian Marick, Artisanal Labrador |
I tried it out and wasn't quite sure if I had it right. You can finish it off if you'd like. |
OK, I'll take a look at it. On Nov 6, 2011, at 6:29 PM, AlexBaranosky wrote:
Brian Marick, Artisanal Labrador |
In 1.3-alpha5 |
Great! Looks like |
It doesn't work to override functions like #'+ because they're inlined. Processing of
provided
should consider an attempt to do so a user error.In Clojure 1.3 (at least), the var for a function that will be inlined has an :inline key in its metadata.
The text was updated successfully, but these errors were encountered: