crystal-lang - 错误:没有重载匹配类型为 (Array(String) | Nil) 的“Log::Context.new”
问题描述
我确实通过官方 docker 镜像更新到 Crystal 0.35.1。不幸的是,我的项目在水晶本身的某个地方出现编译错误错误:没有重载匹配类型为 (Array(String) | Nil) 的“Log::Context.new”。
root@395e51d80ee6:/app# crystal spec --error-trace
In /usr/share/crystal/src/log/entry.cr:43:35
43 | getter context : Metadata = Log.context.metadata
^------
Error: instantiating 'Log.class#context()'
In /usr/share/crystal/src/log/main.cr:56:18
56 | Log::Context.new(Fiber.current.logging_context)
^--
Error: no overload matches 'Log::Context.new' with type (Array(String) | Nil)
Overloads are:
- Log::Context.new(metadata : Metadata)
Nil trace:
/usr/share/crystal/src/log/main.cr:56
Log::Context.new(Fiber.current.logging_context)
^~~~~~~~~~~~~~~
macro property (in expanded macro: macro_140471448844816:630):6
def logging_context : Array(String) | ::Nil
^~~~~~~~~~~~~~~
macro property (in expanded macro: macro_140471448844816:630):7
@logging_context
macro property (in expanded macro: macro_140471448844816:630):4
@logging_context : Array(String) | ::Nil
我的水晶版是
croot@395e51d80ee6:/app# crystal -v
Crystal 0.35.1 [5999ae29b] (2020-06-19)
LLVM: 8.0.0
Default target: x86_64-unknown-linux-gnu
解决方案
我的编译被破坏了require "sidekiq"
(看起来碎片不再维护),我切换到require "mosquito"
. IMO Crystal 编译器应在回溯中显示问题的直接根源。
推荐阅读
- python - 使用 Item Pipelines 清理 Html 标签并在 Scrapy 中获取输出
- html - 为什么 HTML 和 body 元素的高度最初等于视口,但如果内容增加,那么它的高度也会增加?
- sql-server - 如何在 SQL Server 中处理 MMddyyyy 日期格式?
- slack - 无法向 Slack 机器人发送直接消息,功能已关闭
- ruby-on-rails - 如何根据 ruby 中的类型和名称键找到总和?(红宝石哈希数组)
- sql - SQL:给定一个字符串数组,过滤字符串列是否部分包含在该数组中
- reference - ReferenceField React-Admin 中的唯一值
- c# - 将用户重定向到未经授权的页面(临时解决方案)
- javascript - 无法使用 Ionic 5 监听发出的事件
- react-native - 如何指定要在 app.js 中使用的组件?