ClojureScript

with-out-str conflicts with :infer-externs

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: 1.10.238
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    macOS
  • Patch:
    Code
  • Approval:
    Accepted

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#)))

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: