Skip to content

Alias namespaced keyword in custom hiccup element leads to error "failed to parse ns" #34

@thetenter

Description

@thetenter

After happily using shadow-css for some time I think I found an unreported bug.
Thank you so much for this great library. For me it is by far the best css story for clojure.

Context

Problem

  • If at least one custom hiccup element with alias namespaced keyword, e.g. [::my-alias/my-component] is part of a namespace used with shadow-css build process, the following error is thrown: failed to parse ns

Reproduction steps

  1. Build css with shadow-css build process including at least one namespace with at least one alias namespaced keyword as custom hiccup element.

Example:

(ns planning-assistant.ui.components.my-component
  (:require
   [shadow.css :refer (css)]
   [planning-assistant.ui.components.checkbox :as checkbox]))

(def hiccup-using-namespaced-alias-keyword
  [::checkbox/checkbox])

Observed

  • Following error is thrown:
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  failed to parse ns
Data:     {:ns planning-assistant.ui.components.my-component}
Location: shadow/css/analyzer.cljc:379:19

----- Context ------------------------------------------------------------------
375: 
376:               (try
377:                 (reader/read {:eof eof :read-cond :preserve} reader)
378:                 (catch #?(:clj Exception :cljs :default) e
379:                   (throw (ex-info "failed to parse ns" {:ns (:ns state)} e)))))]
                       ^--- failed to parse ns
380: 
381:         (if (identical? form eof)
382:           state
383: 
384:           (let [next-state (find-css-calls state form)]

----- Stack trace --------------------------------------------------------------
shadow.css.analyzer/find-css-in-source    - shadow/css/analyzer.cljc:379:19
shadow.css.analyzer/find-css-in-source    - shadow/css/analyzer.cljc:376:15
shadow.css.analyzer/find-css-in-source    - shadow/css/analyzer.cljc:345:1
shadow.css.build/index-source             - shadow/css/build.cljc:342:9
shadow.css.build/index-source             - shadow/css/build.cljc:340:1
... (run with --debug to see elided elements)
user-0b6ae10c-cd43-4eaf-afac-2bfbd32d76dd - <expr>:26:92
shadow.css.build/generate                 - shadow/css/build.cljc:282:1
user-0b6ae10c-cd43-4eaf-afac-2bfbd32d76dd - <expr>:26:162
shadow.css.build/write-outputs-to         - shadow/css/build.cljc:528:8
user-0b6ae10c-cd43-4eaf-afac-2bfbd32d76dd - <expr>:26:225

Expected

  • No error is thrown.

Demarcation

  • The same example with namespaced keyword as custom hiccup element (without alias) works.
(ns planning-assistant.ui.components.my-component
  (:require
   [shadow.css :refer (css)]
   [planning-assistant.ui.components.checkbox :as checkbox]))

(def hiccup-using-namespaced-alias-keyword
  [:planning-assistant.ui.components.checkbox/checkbox])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions