status-im / nim-chronicles

A crafty implementation of structured logging for Nim.
Apache License 2.0
153 stars 20 forks source link

Bug: Latest commit generates code that does not compiles for nwaku #145

Open NagyZoltanPeter opened 3 months ago

NagyZoltanPeter commented 3 months ago

I had ran into a strange bug when tried to use the latest nim-chronicles in nwaku. From commit: ccbb756 to ab3ab54

After bumping to new version one of our test suit did not compiled.

Steps to repdroduce:

Check error:

/home/nzp/dev/status/nwaku-third/waku/waku_api/rest/store/client.nim(70, 17) template/generic instantiation of `rest` from here
/home/nzp/dev/status/nwaku-third/vendor/nim-presto/presto/client.nim(512, 17) template/generic instantiation of `async` from here
/home/nzp/dev/status/nwaku-third/vendor/nim-presto/presto/client.nim(1161, 20) template/generic instantiation of `setResult` from here
/home/nzp/dev/status/nwaku-third/vendor/nim-presto/presto/client.nim(1170, 44) template/generic instantiation of `error` from here
/home/nzp/dev/status/nwaku-third/vendor/nim-results/results.nim(890, 24) template/generic instantiation of `raiseResultDefect` from here
/home/nzp/dev/status/nwaku-third/vendor/nim-results/results.nim(372, 63) template/generic instantiation of `$` from here
/home/nzp/dev/status/nwaku-third/vendor/nimbus-build-system/vendor/Nim/lib/system/dollars.nim(111, 15) template/generic instantiation of `addQuoted` from here
/home/nzp/dev/status/nwaku-third/vendor/nimbus-build-system/vendor/Nim/lib/system/dollars.nim(153, 21) template/generic instantiation of `collectionToString` from here
/home/nzp/dev/status/nwaku-third/vendor/nimbus-build-system/vendor/Nim/lib/system/dollars.nim(136, 13) template/generic instantiation of `addQuoted` from here
/home/nzp/dev/status/nwaku-third/vendor/nimbus-build-system/vendor/Nim/lib/system/dollars.nim(111, 15) template/generic instantiation of `addQuoted` from here
/home/nzp/dev/status/nwaku-third/vendor/nimbus-build-system/vendor/Nim/lib/pure/options.nim(361, 11) template/generic instantiation of `addQuoted` from here
/home/nzp/dev/status/nwaku-third/vendor/nimbus-build-system/vendor/Nim/lib/system.nim(2929, 11) Error: type mismatch: got <Base64String>
but expected one of:
func `$`(a: Duration): string
first type mismatch at position: 1
required type for a: Duration
but expression 'x' is of type: Base64String
func `$`(a: Moment): string
first type mismatch at position: 1
required type for a: Moment
but expression 'x' is of type: Base64String
func `$`(u: Uri): string
first type mismatch at position: 1
required type for u: Uri
but expression 'x' is of type: Base64String
...
required type for x: set[T]
but expression 'x' is of type: Base64String
template `$`(s: JsonString): string
first type mismatch at position: 1
required type for s: JsonString
but expression 'x' is of type: Base64String

This code compiles just fine with the ccbb756 version. I think latest commit introduced a change in code generation template that cause this error.

In nwaku side the change might be related to this issue:

https://github.com/waku-org/nwaku/blob/361fe2cdc7c48e458a9cd3bb1b38df28f3cda65e/waku/waku_api/rest/store/types.nim#L45 There is a new Option[Base64String] field added. From the compile fail stack I think the issue is when there is a contained type stringify should happen.