jsony icon indicating copy to clipboard operation
jsony copied to clipboard

Bizzare import interaction resulting in `attempting to call undeclared routine: 'toJson'`.

Open dawdmaow opened this issue 10 months ago • 1 comments

This is probably a compiler error, but I wasn't able to come up with a reproduction without jsony.

Nim version: 2.2.0 Backend: c

imported.nim

import pkg/jsony

type
  Foo* = ref object
    foo: float # Remove this line and everything works 🤡

proc serialize*(msg: Foo|float) =
  discard toJson(msg)

main.nim

import imported
# import jsony # Add this line and everything works 🤡

serialize(Foo())

Output

...template/generic instantiation of `toJson` from here
/Users/dawid/.nimble/pkgs2/jsony-1.1.5-6aeb83e7481ca8686396a568096054bc668294df/jsony.nim(881, 11) template/generic instantiation of `dumpHook` from here
/Users/dawid/.nimble/pkgs2/jsony-1.1.5-6aeb83e7481ca8686396a568096054bc668294df/jsony.nim(823, 6) template/generic instantiation of `dumpHook` from here
/Users/dawid/.nimble/pkgs2/jsony-1.1.5-6aeb83e7481ca8686396a568096054bc668294df/jsony.nim(801, 8) template/generic instantiation of `dumpKey` from here
/Users/dawid/.nimble/pkgs2/jsony-1.1.5-6aeb83e7481ca8686396a568096054bc668294df/jsony.nim(739, 15) Error: attempting to call undeclared routine: 'toJson'

dawdmaow avatar Dec 23 '24 00:12 dawdmaow