Open joodie opened 10 years ago
Ah, that's interesting; I never considered the combination of auto-qualifying keywords and aliases. I'll take a look later today.
Thanks for the report!
Hello, I finally had a chance to look at this today.
This Invalid token
error occurs at read-time and therefore never reaches Slamhound's ns regrow loop.
It is possible to add a special-case just for this. It would require:
At a high level then, the reconstruction algorithm becomes:
-> file
asplode-ns
read-body
regrow-ns
stitch-up
@technomancy: Do you think supporting ::alias/sym
is worth the above changes? I am happy to do the work
I'm not sure how this requires a new phase, since reading the body is already the last isolated step of asplode
, but yeah, this seems reasonable.
It doesn't require a new phase, but it avoids making asplode
depend on regrow
. I also think it's nicer if asplode
returns a file's ns form without any interpretation.
Anyway, great! I will push up an implementation tomorrow to a feature branch for review.
This seems more important with clojure 1.9 around the corner.
Yeah, we use this in nearly every ns we have. +1
Requiring a namespace using :as alias, then using the alias to refer to a keyword in that namespace throws an error in slamhound.
Given src/my_test.clj:
Results in:
I think slamhound should parse this as clojure does (AFAIKT this feature has been in clojure since 1.0, though documentation is scarce) and interprets ::alias/word as a requirement to keep the :as alias.