cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
scknkkrer 2019-08-08T20:42:46.017200Z

I know, when I ask this questions and take your time, it’s not the contribution. But, I’ve some questions. I’ve been volunteer for the cljs-3152. Which says; > Throw complier exception when method names start with . special. I think I have to dig down to the Analyzer. Which I did. In Analyzer, parse-invoke* method seems nice to me. I have implement a control that takes name of the fexpr --I think it means; Function Expression--.

(when ^boolean fn-var?
      (let [{^boolean variadic :variadic? :keys [max-fixed-arity method-params name ns macro]} (:info fexpr)]
      (when (= (first name) ;; +------------------------
                ".")
            (throw (new js/Exception))) ;; Do we have a special Exception type for the Compiler Exceptions? + ----------------------------
        ;; don't warn about invalid arity when when compiling a macros namespace
        ;; that requires itself, as that code is not meant to be executed in the
        ;; `$macros` ns - António Monteiro
        (when (and #?(:cljs (not (and (gstring/endsWith (str cur-ns) "$macros")
                                      (symbol-identical? cur-ns ns)
                                      (true? macro))))
                   (invalid-arity? argc method-params variadic max-fixed-arity))
          (warning :fn-arity env {:name name :argc argc}))))
Am I doin’ good ?

thheller 2019-08-08T20:45:27.018100Z

@scknkkrer no. the error should be thrown in def, eg. disallow (defn .xyz [] ...)

thheller 2019-08-08T20:45:51.018500Z

(at least thats my impression from the rather short ticket description)

thheller 2019-08-08T20:46:19.019200Z

the compile will automatically desugar (.foo bar) calls so (.xyz) would not be callable

scknkkrer 2019-08-08T21:07:06.021700Z

That was my first idea. But, I was thinking about, if we do this in the defn macro, it will not be flexible as we will need.

scknkkrer 2019-08-08T21:07:13.021900Z

Maybe, I was wrong.

thheller 2019-08-08T21:14:37.022200Z

not in the macro. probably here https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/analyzer.cljc#L1832

thheller 2019-08-08T21:15:24.022900Z

there are a bunch of checks a bit further down already. looks like a good place to add that check

thheller 2019-08-08T21:18:44.023500Z

but first confirm with David that this is actually what he meant. I might be wrong.

scknkkrer 2019-08-08T21:32:02.024500Z

@dnolen What do you say boss, shall I ?