Uploaded image for project: 'ClojureScript'
  1. CLJS-1237

ns-unmap doesn't work on refers from cljs.core

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects versions: 1.7.145
    • Fix versions: 1.9.671
    • Labels:
    • Patch:
      Code

      Description

      In ClojureScript, using ns-unmap on a symbol from cljs.core doesn't exclude it from the current namespace. Note that both a function and a macro still exist, even after unmapping:

      To quit, type: :cljs/quit  
      cljs.user=> (ns-unmap 'cljs.user 'when) ;; macro
      true  
      cljs.user=> (ns-unmap 'cljs.user 'not)  ;; function
      true  
      cljs.user=> (when 1 2)  
      2  
      cljs.user=> (not false)  
      true  
      

      This differs from the behavior of Clojure's ns-unmap. Note the appropriate errors when attempting to use unmapped symbols:

      Clojure 1.7.0-beta1
      user=> (ns-unmap 'user 'when) ;; macro
      nil
      user=> (ns-unmap 'user 'not)  ;; function
      nil
      user=> (when 1 2)
      CompilerException java.lang.RuntimeException: Unable to resolve symbol: when in this context, compiling:(NO_SOURCE_PATH:11:1) 
      user=> (not false)
      CompilerException java.lang.RuntimeException: Unable to resolve symbol: not in this context, compiling:(NO_SOURCE_PATH:12:1) 
      

      Somehow ClojureScript's ns-unmap needs to add the symbol to the current namespace's :excludes set. Note that the def special form does this already (after it displays a warning).

      We have two solutions. 0001 extends the ns form's :merge behavior to support :excludes, and then uses this in ns-unmap. If the enhancement to ns isn't wanted, patch 0002 changes ns-unmap to update :excludes directly.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              chouser@n01se.net chouser
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: