【问题标题】:Creating new types using Typedef on Vibe.data.json.Json, implicit conversion error在 Vibe.data.json.Json 上使用 Typedef 创建新类型,隐式转换错误
【发布时间】:2016-12-27 14:05:18
【问题描述】:

我需要有多种类型的 Json,所以我使用了Typedef,如下所示:

 alias NewType = Typedef!(Json);

我使用的是 Vibe.d Json 版本,使用 DMD64 D Compiler v2.072.0 编译时收到以下消息:

Error: cannot implicitly convert expression ([cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u]) of type ubyte[] to void[32]

我阅读了文档并没有发现使用 Typedef 的任何限制。

【问题讨论】:

    标签: d dmd vibed


    【解决方案1】:

    这是Typedef 中的一个错误,它似乎无法为使用类型为void 的数组的类型设置别名,来自std_data_json 的JSONValue 也存在同样的问题。在这种情况下,我将这一行:https://github.com/s-ludwig/taggedalgebraic/blob/master/source/taggedalgebraic.d#L58 更改为 ubyte 类型,它现在正在工作。我会尝试进一步查看并修复它。

    Issue link

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-12
      • 2014-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多