Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException when a >defn calls another >defn with invalid arguments #42

Open
whmountains opened this issue May 31, 2021 · 1 comment

Comments

@whmountains
Copy link

whmountains commented May 31, 2021

I accidentally hit enter before I was ready, so apologies to anyone who may have gotten a confusing email notification.

I am getting a NullPointerException related to clojure.string/split-lines when a >defn is being generatively tested, and calls another function with arguments that don't match the spec. I find myself constantly hitting this. Instead of a concise error message I get pages and pages of nested stack traces.

Here is my minimal reproduction.

(>defn inner
       [input]
       [int? => string?]
       (str input))

(>defn outer
       [input]
       [string? => string?]
       (inner input))

(g/check)

It appears the error is coming from line 180 in reporting.cljc. Here is a snippet of the stack trace:

{:file "Matcher.java",
 :line 1770,
 :type :error,
 :expected
 (clojure.core/and
  (clojure.core/every?
   (fn*
    [p1__2441__2443__auto__]
    (clojure.core/->
     p1__2441__2443__auto__
     :clojure.spec.test.check/ret
     :pass?))
   spec-checks__2442__auto__)
  true
  true),
 :actual #error {
 :cause nil
 :via
 [{:type java.lang.NullPointerException
   :message nil
   :at [java.util.regex.Matcher getTextLength "Matcher.java" 1770]}]
 :trace
 [[java.util.regex.Matcher getTextLength "Matcher.java" 1770]
  [java.util.regex.Matcher reset "Matcher.java" 416]
  [java.util.regex.Matcher <init> "Matcher.java" 253]
  [java.util.regex.Pattern matcher "Pattern.java" 1135]
  [java.util.regex.Pattern split "Pattern.java" 1263]
  [java.util.regex.Pattern split "Pattern.java" 1336]
  [clojure.string$split invokeStatic "string.clj" 224]
  [clojure.string$split_lines invokeStatic "string.clj" 228]
  [clojure.string$split_lines invoke "string.clj" 228]
  [ghostwheel.reporting$report_spec_check invokeStatic "reporting.c
ljc" 180]
  [ghostwheel.reporting$report_spec_check invoke "reporting.cljc" 163]
  [ghostwheel.reporting$eval2004$fn__2005 invoke "reporting.cljc" 208]
  [clojure.lang.MultiFn invoke "MultiFn.java" 229]
  [clojure.test$do_report invokeStatic "test.clj" 357]
  [clojure.test$do_report invoke "test.clj" 351]
  [ghostwheel_repr.core$fn__11380 invokeStatic "core.clj" 12]
;; stack trace continues into clojure internals...
]
;; other properties elided
}
@whmountains whmountains changed the title NullPointerException when calling NullPointerException when a >defn calls another >defn with invalid arguments May 31, 2021
@gnl
Copy link
Owner

gnl commented Jul 20, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants