- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
很抱歉问这么基本的问题。希望答案并不明显的事实主要是由于 clojure.spec 仍然是 alpha 版本 (0.1.134)。
如何在此规范错误消息中找到违规代码的文件名和行号? :in
键 sc 的含义是什么。值[2 1]
?
#error {
:cause Call to clojure.core/refer-clojure did not conform to spec:
In: [2 1] val: :as fails at: [:args :exclude :op :quoted-spec :spec] predicate: #{:exclude}
In: [2 1] val: :as fails at: [:args :only :op :quoted-spec :spec] predicate: #{:only}
In: [2 1] val: :as fails at: [:args :rename :op :quoted-spec :spec] predicate: #{:rename}
In: [2] val: (quote :as) fails at: [:args :exclude :op :spec] predicate: #{:exclude}
In: [2] val: (quote :as) fails at: [:args :only :op :spec] predicate: #{:only}
In: [2] val: (quote :as) fails at: [:args :rename :op :spec] predicate: #{:rename}
:data #:clojure.spec.alpha{:problems ({:path [:args :exclude :op :spec], :pred #{:exclude}, :val (quote :as), :via [], :in [2]} {:path [:args :exclude :op :quoted-spec :spec], :pred #{:exclude}, :val :as, :via [], :in [2 1]} {:path [:args :only :op :spec], :pred #{:only}, :val (quote :as), :via [], :in [2]} {:path [:args :only :op :quoted-spec :spec], :pred #{:only}, :val :as, :via [], :in [2 1]} {:path [:args :rename :op :spec], :pred #{:rename}, :val (quote :as), :via [], :in [2]} {:path [:args :rename :op :quoted-spec :spec], :pred #{:rename}, :val :as, :via [], :in [2 1]}), :spec #object[clojure.spec.alpha$regex_spec_impl$reify__1188 0x437e951d clojure.spec.alpha$regex_spec_impl$reify__1188@437e951d], :value ((quote :exclude) (quote [reduce into merge map take partition partition-by]) (quote :as) (quote core)), :args ((quote :exclude) (quote [reduce into merge map take partition partition-by]) (quote :as) (quote core))}
...}
当我输入lein repl
时出现此错误。我对有问题的行的猜测在这里:
(ns fargish.util
(:refer-clojure :exclude [rand rand-int cond])
(:require [better-cond.core :refer [cond]]
[clojure.tools.trace :refer :all]
[clojure.pprint :refer [pprint]]
[clojure.math.numeric-tower :as math]
[clojure.core.async :as async :refer [<! <!! >! >!!]]
[clojure.java.io :as io]
[clojure.edn :as edn]
[popen :refer [popen] :as po]
[cheshire.core :as ch]
[lonocloud.synthread :as ->]))
因为当我从 Clojure 1.8 下运行的目录复制此错误消息时,第一次出现了错误消息。此代码在 Clojure 1.8 下运行。
如果我没有有这个方便的线索,我想知道如何追踪有问题的文件和行。即使有了这条线索,我也不知道该怎么办。我无法判断错误是在我的代码中、在 clojure.core/ns 代码中还是在 clojure.core/ns 中的规范中。另外,In: [2 1]
指的是什么?
更新我发现了错误。我上面的猜测是错误的。该错误甚至不在我的代码中!它位于 clojure.core.async 中。我使用的是旧版本:0.2.374。我更改为当前版本 0.3.443,错误消息就此结束。显然,Clojure 1.9 之前编写的许多代码都利用了 ns
宏中的一些松懈,例如在 :require
和其他关键字之前省略了冒号,因此这将是常见问题,直到库更新并且依赖项更新以指向更新的库。类似的错误出现在popen中(已经修复了——服务很快!)。
不过,我的问题不是关于此错误的具体情况。这是关于一般问题:如何找到有问题的代码行,而不需要像这样通过反复试验进行长时间的追踪。
最佳答案
当您在 ns
形式中犯错误时,您收到的错误消息会非常糟糕(比“平均错误”Clojure 错误消息更糟糕)。我发现的唯一解决方案是在测试运行之间保持非常有限的更改数量。
我使用的另一种技术是在 Google 中搜索可以复制的正确代码示例。我今天使用该技术来找到正确的语法:
(ns xyz
(:require
[clojure.spec.alpha :as sp]
[clojure.spec.gen.alpha :as gen]
[clojure.spec.test.alpha :as stest] ))
(stest/check `i/truthy? {:clojure.spec.test.check/opts {:num-tests 99}})
请注意,与 require
语句不同,关键字命名空间中没有“alpha”,这进一步造成了困惑。我敢让你尝试猜出正确答案from the online docs :
Usage: (check) (check sym-or-syms) (check sym-or-syms opts) Run generative tests for spec conformance on vars named by sym-or-syms, a symbol or collection of symbols. If sym-or-syms is not specified, check all checkable vars.
The opts map includes the following optional keys, where stc aliases clojure.spec.test.check:
::stc/opts opts to flow through test.check/quick-check :gen
map from spec names to generator overridesThe ::stc/opts include :num-tests in addition to the keys documented by test.check. Generator overrides are passed to spec/gen when generating function args.
如果所有其他方法都失败了,你别无选择,只能使用历史悠久的技术,找到一个确实有效的 super 最小案例,然后一次为你的目标添加一个小的改变,直到实现失败。我经常发现在一个新的、干净的 lein 项目中进行此类实验更容易,因此我确信不存在混淆该问题的未知问题。
<小时/>附注你可以随时询问别人。选择以下一项或多项:
关于Clojure 规范错误消息 : filename? 行号? :in?的含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46615500/
我有名为 xxx.java.i、xxx.java.d、xxx.jar.i 的文件。我知道这些文件与 Java 有某种关系。这个扩展是什么意思以及它的用途是什么?它与 .class 扩展名的类型相同吗?
我的命名尽量在语法上正确*。我一直使用 filename 而不是 fileName。 java 约定似乎也使用这个,但 FxCop 更喜欢 fileName。 有一个discussion on Wik
来自MISRA-C 2004 : 19.3 (req): The '#include' directive shall be followed by either a or "filename" s
我有一个 SKScene 类,我需要在其中实现一个自定义初始化程序来覆盖 SKScene 父类(super class) SKNode 的初始化程序 init(fileNamed: fileNamed
在 C 和 C++ 编程语言中,在 include 中使用尖括号和使用引号有什么区别?声明,如下? #include #include "filename" 最佳答案 实际上,区别在于预处理器搜索包
我想解压一个文件,例如使用 shell 命令将“tar123.tar.gz”复制到目录/myunzip/tar123/”。 tar -xf tar123.tar.gz 将解压缩文件,但在与我工作的目录
我是 C 语言新手,我知道这两个命令都完成相同的任务,但是其中一个命令是否会执行与另一个命令不同的操作? 最佳答案 首先,如果您使用 make,那么对于 hello.c,您将调用 make 作为 ma
我正在编写一个程序,它将文件名列表存储为字符串数组。当我将其声明为 char *filenames[1] 我没有错误......但是当我这样做时 char *filenames 我遇到了一些错误。不在
我在将 Appirater 集成到我的应用程序时遇到了一些问题。我已经正确添加了所有必要的文件,并拥有正确的代码(我认为),但是在尝试将其实现到我的 AppDelegate.m 文件中时出现错误。当我
在 include 中使用尖括号和引号有什么区别?指令? #include <filename> #include "filename"
我目前正在寻找一种批量获取变量并仅解析文件名的方法。 例如,我将来自另一个应用程序的 -s 参数传递给我的批处理文件,该参数随后被设置为我的源变量。源文件变量通常包含如下内容:C:\Program F
在 GNU Makefile(在 Ubuntu Linux 系统上)中,如何删除列表中每个文件名的文件名后缀,以便在第一个点处截断文件名? 假设我有 NAMES = file1.a.b.c file2
我正在尝试从源代码安装rtorrent,但是在编译时出现错误。我正在使用新的Ubuntu 20.04 VM。 libtorrent安装 sudo apt update sudo apt upgrade
在 GNU Makefile(在 Ubuntu Linux 系统上)中,如何删除列表中每个文件名的文件名后缀,以便在第一个点处截断文件名? 假设我有 NAMES = file1.a.b.c file2
1-intro-to deepleanring and computer visionk.MKV 2.Kaggle Deep Learning - YouTube.MP4 Convolutional
我希望 gvim 始终在单独的窗口中打开并立即返回命令提示符。换句话说我想要 gvim filename 与相同 gvim filename & 看来我应该可以用别名来做到这一点。别名是否有特殊的通配
以下代码发送一个 GET 请求,该请求的响应应该在客户端 (Chrome) 上启动文件下载过程。 $.ajax({ type: "GET", traditional: true, asyn
我有一堆 filename.bz2.gz 的文件,我想将其转换为 filename.gz。 有什么帮助吗? 谢谢 最佳答案 有了您的文件名*.bz2.gz,我假设该文件是使用以下压缩顺序创建的: ec
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicate: Reference - What does this symbol mean in PHP? 我正在制作一个
如何合并 abc.mp4.tmp 与实际 交换文件abc.mp4 文件。我试图使用 Wowza Media server 3.6 录制现场事件,但录制的文件在最后一刻没有正确混合。 abc.mp4.t
我是一名优秀的程序员,十分优秀!