clojure.spec/fn-specs vs aliased symbols

113 views
Skip to first unread message

Laszlo Török

unread,
Jun 12, 2016, 2:05:03 PM6/12/16
to Clojure Dev
Hi,

I've been experimenting with clojure.spec over the weekend and discovered a potential issue with how fn-specs resolves aliased symbols.

I didn't have time to get to the bottom of it, however, here is a minimal example to demonstrate it:

https://gist.github.com/laczoka/acd65028f5a46338e33c940d49d01753

Regards,

Laszlo

P.S. Thank you very much everyone who put this fantastic toolbox together.

Alex Miller

unread,
Jun 14, 2016, 5:49:28 PM6/14/16
to Clojure Dev
Hi Laszlo,

Things have changed a bit fdef and fn-spec (was fn-specs) in alpha6 but I think this issue is the same - the symbol passed to fn-spec is used as is to do the lookup so won't resolve against local aliases. If you could file that as a jira I will go over it with Rich at some point.

Alex

László Török

unread,
Jun 15, 2016, 4:48:42 AM6/15/16
to cloju...@googlegroups.com
Thanks Alex for getting back, I'll have a look at alpha6 and file and open a JIRA ticket if needed.

Laszlo

--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev...@googlegroups.com.
To post to this group, send email to cloju...@googlegroups.com.
Visit this group at https://groups.google.com/group/clojure-dev.
For more options, visit https://groups.google.com/d/optout.



--
László Török

László Török

unread,
Jun 15, 2016, 10:36:00 AM6/15/16
to cloju...@googlegroups.com
Hi Alex,

fn-spec now looks much better in that it behaves consistently and doesn't do implicit resolutions.

The following 

(sp/fdef + :args (sp/cat :operand (sp/* number?)))

(sp/fn-spec +) ;; => nil
(sp/fn-spec '+) ;; => nil
(sp/fn-spec 'clojure.core/+) ;; this actually returns the fn-specs

will probably be a source of annoying bugs for some, until they learn that they should only pass fully namespace qualified quoted symbols to fn-spec.

Perhaps the docstring could be more explicit on this, but I don't have a strong opinion.

Thanks,

Laszlo
--
László Török

Alex Miller

unread,
Jun 15, 2016, 10:57:58 AM6/15/16
to cloju...@googlegroups.com
I think you should file a ticket and we can decide whether this is actually the correct behavior.

László Török

unread,
Jun 15, 2016, 12:26:37 PM6/15/16
to cloju...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages