technomancy / slamhound

Slamhound rips your namespace form apart and reconstructs it.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Qualified references inside syntax-quote aren't caught

technomancy opened this issue · comments

This type of reference typically doesn't cause a compilation failure in the namespace containing the reference itself; only namespaces that consume the macro trigger failures.

There may be some clever tricks we could pull to help with this, but this is a hole in the existing logic.

I think @Francis- is looking into some ideas for this. But I think it is experimental.

Did you have any thoughts on ways this could be done?

I've thought a bit about trying to walk all defmacro bodies in the namespace and check for symbols with a namespace, but that would almost positively result in false positives. I can't think of a solution better than simply recommending users place metadata on the macro definition like so:

(defmacro ^{:requires [a/b c/d]} my-macro [q p & body]
  `(let [~'q a/b, ~'p c/d] ~@body))

The meta key used is immaterial, and Slamhound wouldn't check for it specifically, but the presence of a reference to the vars would trigger a compilation failure that Slamhound needs to find the required var.

So I think it's just something we need to document.

To clarify, I'm open for suggestions on alternate approaches here, but I'd rather not handle this than handle this in a way that would have edge cases which could make it go looking for vars that don't exist.

Yes, I agree. So far I haven't thought of anything.

Sounds like a job for tools.analyzer.

@hugoduncan

Yes! It's on the todo list, but I've been waiting for a stable release. Do you think it's ready?