-
Notifications
You must be signed in to change notification settings - Fork 129
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
tabular
+ fact
interaction can create invalid var names
#472
Comments
tablular
+ fact
interaction can create invalid var namestabular
+ fact
interaction can create invalid var names
Hi @vemv, I ran the following and it passed fine: (ns matcher-combinators.scratch
(:require [midje.sweet :refer :all]
[clojure.string :as str]
[matcher-combinators.result :as result]
[matcher-combinators.midje :refer [match]]
[matcher-combinators.core :as core]
[matcher-combinators.matchers :as matchers]))
(tabular
(fact "Providing seq/map matcher with incorrect input leads to automatic mismatch"
(core/match (?matcher 1) 1)
=> (just {::result/type :mismatch
::result/value (contains {:expected-type-msg
#(str/starts-with? % (-> ?matcher var meta :name str))
:provided
"provided: 1"})
::result/weight number?}))
?matcher
matchers/prefix
matchers/embeds) That said, I did get tripped up because (tabular
(fact "Providing seq/map matcher with incorrect input leads to automatic mismatch"
(core/match (?matcher 1) 1)
=> any?)
?matcher
i-dont-exist/equals) results in
Is that somehow related to what you are getting at? |
Thanks for the response. Indeed the However, did you check out the names of the var objects that get created out of a |
well, a green build doesn't always mean a correct implementation :) but I'm still not following. A code snippet that shows the odd characters/whitespace you are referring to would be helpful. For example, I macroexpanded the
|
Hi again! Did you check out the name of the var that gets created by evaluating As mentioned, this var name seems fishy in itself, and probably the easiest thing that both of us can reproduce. |
hmm, I'm not seeing any vars created when I inspect the namespace using
|
Alright, I'll try to provide a repro repo, as this might be related to an unlucky combination of deps or such |
I've just hit by this in tests for tablecloth (https://github.com/scicloj/tablecloth/blob/master/test/tablecloth/api/reshape_test.clj#L9) When I run Maybe something wrong with Cider?
It happens for all of tests in (fact "asdf" (tabular (fact (seq ?n) => ?v)
?n ?v
[1 2 3] [1 2 3])) 2. Unhandled clojure.lang.Compiler$CompilerException
Error compiling test/tablecloth/api/reshape_test.clj at (9:1)
#:clojure.error{:phase :macro-syntax-check,
:line 9,
:column 1,
:source
"/home/XXX/clojure/tablecloth/test/tablecloth/api/reshape_test.clj",
:symbol clojure.core/defn}
Compiler.java: 6976 clojure.lang.Compiler/checkSpecs
Compiler.java: 6992 clojure.lang.Compiler/macroexpand1
core.clj: 4012 clojure.core/macroexpand-1
core.clj: 4014 clojure.core/macroexpand
core.clj: 4022 clojure.core/macroexpand
core.clj: 4014 clojure.core/macroexpand
tabular.clj: 71 midje.parsing.0-to-fact-form.tabular/parse/fn
error_handling.clj: 38 midje.parsing.util.error-handling/parse-and-catch-failure
error_handling.clj: 17 midje.parsing.util.error-handling/parse-and-catch-failure
tabular.clj: 66 midje.parsing.0-to-fact-form.tabular/parse
tabular.clj: 65 midje.parsing.0-to-fact-form.tabular/parse
sweet.clj: 221 midje.sweet/tabular
sweet.clj: 208 midje.sweet/tabular
RestFn.java: 142 clojure.lang.RestFn/applyTo
Var.java: 705 clojure.lang.Var/applyTo
Compiler.java: 6997 clojure.lang.Compiler/macroexpand1
core.clj: 4012 clojure.core/macroexpand-1
core.clj: 4014 clojure.core/macroexpand
core.clj: 4014 clojure.core/macroexpand
facts.clj: 121 midje.parsing.1-to-explicit-form.facts/midjcoexpand
facts.clj: 108 midje.parsing.1-to-explicit-form.facts/midjcoexpand
core.clj: 2759 clojure.core/map/fn
LazySeq.java: 42 clojure.lang.LazySeq/sval
LazySeq.java: 51 clojure.lang.LazySeq/seq
RT.java: 535 clojure.lang.RT/seq
core.clj: 139 clojure.core/seq
core.clj: 2750 clojure.core/map/fn
LazySeq.java: 42 clojure.lang.LazySeq/sval
LazySeq.java: 51 clojure.lang.LazySeq/seq
Cons.java: 39 clojure.lang.Cons/next
PersistentList.java: 37 clojure.lang.PersistentList$Primordial/doInvoke
RestFn.java: 137 clojure.lang.RestFn/applyTo
core.clj: 667 clojure.core/apply
core.clj: 662 clojure.core/apply
laziness.clj: 15 midje.util.laziness/eagerly
laziness.clj: 5 midje.util.laziness/eagerly
facts.clj: 124 midje.parsing.1-to-explicit-form.facts/midjcoexpand
facts.clj: 108 midje.parsing.1-to-explicit-form.facts/midjcoexpand
facts.clj: 162 midje.parsing.1-to-explicit-form.facts/expand-fact-body
facts.clj: 154 midje.parsing.1-to-explicit-form.facts/expand-fact-body
facts.clj: 200 midje.parsing.1-to-explicit-form.facts/complete-fact-transformation
facts.clj: 196 midje.parsing.1-to-explicit-form.facts/complete-fact-transformation
sweet.clj: 194 midje.sweet/fact/fn
error_handling.clj: 41 midje.parsing.util.error-handling/parse-and-catch-failure
error_handling.clj: 17 midje.parsing.util.error-handling/parse-and-catch-failure
sweet.clj: 186 midje.sweet/fact
sweet.clj: 170 midje.sweet/fact
RestFn.java: 142 clojure.lang.RestFn/applyTo
Var.java: 705 clojure.lang.Var/applyTo
Compiler.java: 6997 clojure.lang.Compiler/macroexpand1
Compiler.java: 7079 clojure.lang.Compiler/macroexpand
Compiler.java: 7165 clojure.lang.Compiler/eval
Compiler.java: 7640 clojure.lang.Compiler/load
REPL: 1 user/eval46941
REPL: 1 user/eval46941
Compiler.java: 7181 clojure.lang.Compiler/eval
Compiler.java: 7136 clojure.lang.Compiler/eval
core.clj: 3202 clojure.core/eval
core.clj: 3198 clojure.core/eval
interruptible_eval.clj: 87 nrepl.middleware.interruptible-eval/evaluate/fn/fn
AFn.java: 152 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 667 clojure.core/apply
core.clj: 1977 clojure.core/with-bindings*
core.clj: 1977 clojure.core/with-bindings*
RestFn.java: 425 clojure.lang.RestFn/invoke
interruptible_eval.clj: 87 nrepl.middleware.interruptible-eval/evaluate/fn
main.clj: 437 clojure.main/repl/read-eval-print/fn
main.clj: 437 clojure.main/repl/read-eval-print
main.clj: 458 clojure.main/repl/fn
main.clj: 458 clojure.main/repl
main.clj: 368 clojure.main/repl
RestFn.java: 137 clojure.lang.RestFn/applyTo
core.clj: 667 clojure.core/apply
core.clj: 662 clojure.core/apply
regrow.clj: 20 refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 84 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 56 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 152 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
AFn.java: 22 clojure.lang.AFn/run
session.clj: 202 nrepl.middleware.session/session-exec/main-loop/fn
session.clj: 201 nrepl.middleware.session/session-exec/main-loop
AFn.java: 22 clojure.lang.AFn/run
Thread.java: 832 java.lang.Thread/run |
We both use CIDER so yeah that's a lead :) Could you post the root exception? I think you can obtain it via |
Sure: Syntax error macroexpanding clojure.core/defn at (test/tablecloth/api/reshape_test.clj:9:1).
(api/column-names ds)45000 - failed: simple-symbol? at: [:fn-name] spec: :clojure.core.specs.alpha/defn-args
user> (.getCause *e)
#error {
:cause "Call to clojure.core/defn did not conform to spec."
:data #:clojure.spec.alpha{:problems [{:path [:fn-name], :pred clojure.core/simple-symbol?, :val (api/column-names ds)45000, :via [:clojure.core.specs.alpha/defn-args :clojure.core.specs.alpha/defn-args], :in [0]}], :spec #object[clojure.spec.alpha$regex_spec_impl$reify__2510 0x4e253f65 "clojure.spec.alpha$regex_spec_impl$reify__2510@4e253f65"], :value ((api/column-names ds)45000 [] (midje.checking.facts/creation-time-check (clojure.core/with-meta (clojure.core/fn [] (midje.parsing.util.wrapping/midje-wrapped (midje.data.prerequisite-state/with-installed-fakes (midje.parsing.1-to-explicit-form.parse-background/background-fakes) (midje.parsing.util.wrapping/midje-wrapped (midje.checking.checkables/check-one (clojure.core/merge {:description (midje.data.nested-facts/descriptions), :expected-result-form (quote (quote (:$column :$value))), :check-expectation :expect-match, :midje.parsing.lexical-maps/a-midje-checkable-map? true, :function-under-test (clojure.core/fn [] (api/column-names ds)), :expected-result (quote (:$column :$value)), :position (pointer.core/line-number-known 13), :namespace clojure.core/*ns*} {:arrow (quote =>), :call-form (quote (api/column-names ds))} (clojure.core/hash-map :position (pointer.core/line-number-known 13) :position (pointer.core/line-number-known 13))) []))))) (clojure.core/merge #:midje{:guid "e09930609b3757665a0418142994d1824e439d4e", :source (quote (fact (api/column-names ds) => (quote (:$column :$value)) :position (pointer.core/line-number-known 13))), :namespace (quote tablecloth.api.reshape-test), :file "/home/XXX/clojure/tablecloth/test/tablecloth/api/reshape_test.clj", :line 13} #:midje{:top-level-fact? false})))), :args ((api/column-names ds)45000 [] (midje.checking.facts/creation-time-check (clojure.core/with-meta (clojure.core/fn [] (midje.parsing.util.wrapping/midje-wrapped (midje.data.prerequisite-state/with-installed-fakes (midje.parsing.1-to-explicit-form.parse-background/background-fakes) (midje.parsing.util.wrapping/midje-wrapped (midje.checking.checkables/check-one (clojure.core/merge {:description (midje.data.nested-facts/descriptions), :expected-result-form (quote (quote (:$column :$value))), :check-expectation :expect-match, :midje.parsing.lexical-maps/a-midje-checkable-map? true, :function-under-test (clojure.core/fn [] (api/column-names ds)), :expected-result (quote (:$column :$value)), :position (pointer.core/line-number-known 13), :namespace clojure.core/*ns*} {:arrow (quote =>), :call-form (quote (api/column-names ds))} (clojure.core/hash-map :position (pointer.core/line-number-known 13) :position (pointer.core/line-number-known 13))) []))))) (clojure.core/merge #:midje{:guid "e09930609b3757665a0418142994d1824e439d4e", :source (quote (fact (api/column-names ds) => (quote (:$column :$value)) :position (pointer.core/line-number-known 13))), :namespace (quote tablecloth.api.reshape-test), :file "/home/XXX/clojure/tablecloth/test/tablecloth/api/reshape_test.clj", :line 13} #:midje{:top-level-fact? false}))))}
:via
[{:type clojure.lang.ExceptionInfo
:message "Call to clojure.core/defn did not conform to spec."
:data #:clojure.spec.alpha{:problems [{:path [:fn-name], :pred clojure.core/simple-symbol?, :val (api/column-names ds)45000, :via [:clojure.core.specs.alpha/defn-args :clojure.core.specs.alpha/defn-args], :in [0]}], :spec #object[clojure.spec.alpha$regex_spec_impl$reify__2510 0x4e253f65 "clojure.spec.alpha$regex_spec_impl$reify__2510@4e253f65"], :value ((api/column-names ds)45000 [] (midje.checking.facts/creation-time-check (clojure.core/with-meta (clojure.core/fn [] (midje.parsing.util.wrapping/midje-wrapped (midje.data.prerequisite-state/with-installed-fakes (midje.parsing.1-to-explicit-form.parse-background/background-fakes) (midje.parsing.util.wrapping/midje-wrapped (midje.checking.checkables/check-one (clojure.core/merge {:description (midje.data.nested-facts/descriptions), :expected-result-form (quote (quote (:$column :$value))), :check-expectation :expect-match, :midje.parsing.lexical-maps/a-midje-checkable-map? true, :function-under-test (clojure.core/fn [] (api/column-names ds)), :expected-result (quote (:$column :$value)), :position (pointer.core/line-number-known 13), :namespace clojure.core/*ns*} {:arrow (quote =>), :call-form (quote (api/column-names ds))} (clojure.core/hash-map :position (pointer.core/line-number-known 13) :position (pointer.core/line-number-known 13))) []))))) (clojure.core/merge #:midje{:guid "e09930609b3757665a0418142994d1824e439d4e", :source (quote (fact (api/column-names ds) => (quote (:$column :$value)) :position (pointer.core/line-number-known 13))), :namespace (quote tablecloth.api.reshape-test), :file "/home/XXX/clojure/tablecloth/test/tablecloth/api/reshape_test.clj", :line 13} #:midje{:top-level-fact? false})))), :args ((api/column-names ds)45000 [] (midje.checking.facts/creation-time-check (clojure.core/with-meta (clojure.core/fn [] (midje.parsing.util.wrapping/midje-wrapped (midje.data.prerequisite-state/with-installed-fakes (midje.parsing.1-to-explicit-form.parse-background/background-fakes) (midje.parsing.util.wrapping/midje-wrapped (midje.checking.checkables/check-one (clojure.core/merge {:description (midje.data.nested-facts/descriptions), :expected-result-form (quote (quote (:$column :$value))), :check-expectation :expect-match, :midje.parsing.lexical-maps/a-midje-checkable-map? true, :function-under-test (clojure.core/fn [] (api/column-names ds)), :expected-result (quote (:$column :$value)), :position (pointer.core/line-number-known 13), :namespace clojure.core/*ns*} {:arrow (quote =>), :call-form (quote (api/column-names ds))} (clojure.core/hash-map :position (pointer.core/line-number-known 13) :position (pointer.core/line-number-known 13))) []))))) (clojure.core/merge #:midje{:guid "e09930609b3757665a0418142994d1824e439d4e", :source (quote (fact (api/column-names ds) => (quote (:$column :$value)) :position (pointer.core/line-number-known 13))), :namespace (quote tablecloth.api.reshape-test), :file "/home/XXX/clojure/tablecloth/test/tablecloth/api/reshape_test.clj", :line 13} #:midje{:top-level-fact? false}))))}
:at [clojure.spec.alpha$macroexpand_check invokeStatic "alpha.clj" 712]}]
:trace
[[clojure.spec.alpha$macroexpand_check invokeStatic "alpha.clj" 712]
[clojure.spec.alpha$macroexpand_check invoke "alpha.clj" 704]
[clojure.lang.AFn applyToHelper "AFn.java" 156]
[clojure.lang.AFn applyTo "AFn.java" 144]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.lang.Compiler checkSpecs "Compiler.java" 6974]
[clojure.lang.Compiler macroexpand1 "Compiler.java" 6992]
[clojure.core$macroexpand_1 invokeStatic "core.clj" 4012]
[clojure.core$macroexpand invokeStatic "core.clj" 4014]
[clojure.core$macroexpand invokeStatic "core.clj" 4022]
[clojure.core$macroexpand invoke "core.clj" 4014]
[midje.parsing.1_to_explicit_form.facts$midjcoexpand invokeStatic "facts.clj" 120]
[midje.parsing.1_to_explicit_form.facts$midjcoexpand invoke "facts.clj" 108]
[clojure.core$map$fn__5885 invoke "core.clj" 2757]
[clojure.lang.LazySeq sval "LazySeq.java" 42]
[clojure.lang.LazySeq seq "LazySeq.java" 51]
[clojure.lang.RT seq "RT.java" 535]
[clojure.core$seq__5420 invokeStatic "core.clj" 139]
[clojure.core$map$fn__5885 invoke "core.clj" 2750]
[clojure.lang.LazySeq sval "LazySeq.java" 42]
[clojure.lang.LazySeq seq "LazySeq.java" 51]
[clojure.lang.RT seq "RT.java" 535]
[clojure.core$seq__5420 invokeStatic "core.clj" 139]
[clojure.core$apply invokeStatic "core.clj" 662]
[clojure.core$apply invoke "core.clj" 662]
[midje.util.laziness$eagerly invokeStatic "laziness.clj" 15]
[midje.util.laziness$eagerly invoke "laziness.clj" 5]
[midje.parsing.1_to_explicit_form.facts$midjcoexpand invokeStatic "facts.clj" 124]
[midje.parsing.1_to_explicit_form.facts$midjcoexpand invoke "facts.clj" 108]
[clojure.core$map$fn__5885 invoke "core.clj" 2759]
[clojure.lang.LazySeq sval "LazySeq.java" 42]
[clojure.lang.LazySeq seq "LazySeq.java" 51]
[clojure.lang.RT seq "RT.java" 535]
[clojure.core$seq__5420 invokeStatic "core.clj" 139]
[clojure.core$map$fn__5885 invoke "core.clj" 2750]
[clojure.lang.LazySeq sval "LazySeq.java" 42]
[clojure.lang.LazySeq seq "LazySeq.java" 51]
[clojure.lang.Cons next "Cons.java" 39]
[clojure.lang.PersistentList$Primordial doInvoke "PersistentList.java" 37]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$apply invoke "core.clj" 662]
[midje.util.laziness$eagerly invokeStatic "laziness.clj" 15]
[midje.util.laziness$eagerly invoke "laziness.clj" 5]
[midje.parsing.1_to_explicit_form.facts$midjcoexpand invokeStatic "facts.clj" 124]
[midje.parsing.1_to_explicit_form.facts$midjcoexpand invoke "facts.clj" 108]
[midje.parsing.1_to_explicit_form.facts$expand_fact_body invokeStatic "facts.clj" 162]
[midje.parsing.1_to_explicit_form.facts$expand_fact_body invoke "facts.clj" 154]
[midje.parsing.1_to_explicit_form.facts$complete_fact_transformation invokeStatic "facts.clj" 200]
[midje.parsing.1_to_explicit_form.facts$complete_fact_transformation invoke "facts.clj" 196]
[midje.sweet$fact$fn__44887 invoke "sweet.clj" 194]
[midje.parsing.util.error_handling$parse_and_catch_failure invokeStatic "error_handling.clj" 41]
[midje.parsing.util.error_handling$parse_and_catch_failure invoke "error_handling.clj" 17]
[midje.sweet$fact invokeStatic "sweet.clj" 186]
[midje.sweet$fact doInvoke "sweet.clj" 170]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.lang.Compiler macroexpand1 "Compiler.java" 6997]
[clojure.lang.Compiler macroexpand "Compiler.java" 7079]
[clojure.lang.Compiler eval "Compiler.java" 7165]
[clojure.lang.Compiler eval "Compiler.java" 7136]
[clojure.core$eval invokeStatic "core.clj" 3202]
[clojure.core$eval invoke "core.clj" 3198]
[nrepl.middleware.interruptible_eval$evaluate$fn__949$fn__950 invoke "interruptible_eval.clj" 87]
[clojure.lang.AFn applyToHelper "AFn.java" 152]
[clojure.lang.AFn applyTo "AFn.java" 144]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$with_bindings_STAR_ invokeStatic "core.clj" 1977]
[clojure.core$with_bindings_STAR_ doInvoke "core.clj" 1977]
[clojure.lang.RestFn invoke "RestFn.java" 425]
[nrepl.middleware.interruptible_eval$evaluate$fn__949 invoke "interruptible_eval.clj" 87]
[clojure.main$repl$read_eval_print__9112$fn__9115 invoke "main.clj" 437]
[clojure.main$repl$read_eval_print__9112 invoke "main.clj" 437]
[clojure.main$repl$fn__9121 invoke "main.clj" 458]
[clojure.main$repl invokeStatic "main.clj" 458]
[clojure.main$repl doInvoke "main.clj" 368]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$apply invoke "core.clj" 662]
[refactor_nrepl.ns.slam.hound.regrow$wrap_clojure_repl$fn__17903 doInvoke "regrow.clj" 20]
[clojure.lang.RestFn invoke "RestFn.java" 1523]
[nrepl.middleware.interruptible_eval$evaluate invokeStatic "interruptible_eval.clj" 84]
[nrepl.middleware.interruptible_eval$evaluate invoke "interruptible_eval.clj" 56]
[nrepl.middleware.interruptible_eval$interruptible_eval$fn__980$fn__984 invoke "interruptible_eval.clj" 152]
[clojure.lang.AFn run "AFn.java" 22]
[nrepl.middleware.session$session_exec$main_loop__1048$fn__1052 invoke "session.clj" 202]
[nrepl.middleware.session$session_exec$main_loop__1048 invoke "session.clj" 201]
[clojure.lang.AFn run "AFn.java" 22]
[java.lang.Thread run "Thread.java" 832]]} |
@philomates As a humble suggestion, I wonder if it has to do with some I see there's a number of ^:dynamic vars in Midje. |
I've created minimal project to test some of the paths. So: deps.edn{:deps {org.clojure/clojure {:mvn/version "1.10.3"}
midje/midje {:mvn/version "1.9.9"}}} project.clj(defproject midjebug "0.1.0-SNAPSHOT"
:plugins [[lein-tools-deps "0.4.5"]]
:middleware [lein-tools-deps.plugin/resolve-dependencies-with-deps-edn]
:lein-tools-deps/config {:config-files [:install :user :project]}) test/midjebug/core_test.clj(ns midjebug.core-test
(:require [midje.sweet :refer [fact tabular =>]]))
(fact "test midje bug under Cider"
(tabular (fact ?l => ?r)
?l ?r
1 1)) Versions
After
|
Thanks for the reproduction steps @genmeblog! I'll take a look at it this week and report back |
okay, I installed spacemacs and spun this up. |
@philomates midje-nrepl has a middleware that binds the dynamic var By binding this var I think that you will be able to reproduce the issue without depending on midje-nrepl. @vemv if the issue is bothering you, you can disable the aforementioned behavior by running
|
Hi! I found the following issue.
We can observe that Midje emits delicate-looking var names:
Which becomes problematic when running more substantial code:
Could you please look into emitting more var names having a less risky character set?
Thanks - V
The text was updated successfully, but these errors were encountered: