Skip to content

Bad arg-type error shown (but ignored) for Files/write invocation #355

@rbrw

Description

@rbrw

Perhaps the code below is incorrect somehow, but if not, I see an error like this

Error: Bad arg-type nil for method named write for class java.nio.file.Files, full arg type li
st (java.lang.Object, [B, nil).  ast pprinted below for debugging tools.analyzer:
{:op :static-call,
 :children [:args],
 :eastwood/path [3 :init :expr :methods 0 :body :ret :statements 0],
 :tag java.nio.file.Path,
 :form
 ^{:line 17}

when running eastwood on this code:

(ns eastwood-error.core
  (:gen-class)
  (:import
   (java.nio.file Files OpenOption)))

(defmacro ignore-value
  "Suppress eastwood's unused-ret-vals warning:
  https://github.com/jonase/eastwood#unused-ret-vals.  See
  ./eastwood.clj for the suppression that makes this work."
  [x]
  `(do ~x nil))

(defn crash? [path item]
  (ignore-value
   (Files/write path (byte-array 10) (into-array OpenOption []))))

and it's presence doesn't seem to matter, bu the ./eastwood.clj suppression was:

(disable-warning
 {:linter :unused-ret-vals
  :if-inside-macroexpansion-of #{'some.where/ignore-value}
  :within-depth 2
  :reason "ignore-value is intended to suppress this linter."})

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