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

with-out-str conflicts with :infer-externs

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Completed
    • Affects versions: 1.10.238
    • Fix versions: None
    • Labels:
    • Environment:

      macOS

    • Approval:
      Accepted
    • Patch:
      Code

      Description

      (println (with-out-str (println "bug")))

      Produces the following warning by producing a wrong inferred-externs.js:

      WARNING: target/node/dev/inferred_externs.js:3: WARNING - name goog is not defined in the externs.
      goog.string;
      ^^^^
      
      Jun 16, 2018 2:55:45 PM com.google.javascript.jscomp.LoggerErrorManager println
      WARNING: target/node/dev/inferred_externs.js:4: WARNING - name goog is not defined in the externs.
      goog.string.StringBuffer;
      ^^^^
      
      Jun 16, 2018 2:55:45 PM com.google.javascript.jscomp.LoggerErrorManager println
      WARNING: target/node/dev/inferred_externs.js:5: WARNING - name goog is not defined in the externs.
      goog.string.StringBuffer.prototype.append;
      ^^^^
      

      The problem seems to go away when removing the "js/" below on "js/goog.string.StringBuffer.":

      (core/defmacro with-out-str
        "Evaluates exprs in a context in which *print-fn* is bound to .append
        on a fresh StringBuffer.  Returns the string created by any nested
        printing calls."
        [& body]
        `(let [sb# (js/goog.string.StringBuffer.)]
           (binding [cljs.core/*print-newline* true
                     cljs.core/*print-fn* (fn [x#] (.append sb# x#))]
             ~@body)
           (cljs.core/str sb#)))
      

        Attachments

          Activity

            People

            • Assignee:
              dnolen David Nolen
              Reporter:
              alex+import import
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: