import strutils
type
App = ref object of RootObj
i: int
proc isDigit(app: App) =
discard
macro xconnect(widget: RootRef; signal: string; p: typed; arg: typed; ignoreArg: bool): untyped =
discard
proc main =
let app: App = nil
xconnect(app, "activate", isDigit, "", true)
main()
#
# nim -v
# Nim Compiler Version 0.17.2 (2017-09-08) [Linux: amd64]
# Copyright (c) 2006-2017 by Andreas Rumpf
# $ nim c button.nim
# button.nim(15, 11) Error: type mismatch: got (App, string, proc (app: App){.noSideEffect, gcsafe, locks: 0.} | proc (c: char): bool{.noSideEffect, gcsafe, locks: 0.} | proc (s: string): bool{.noSideEffect, gcsafe, locks: 0.}, string, bool)
# but expected one of:
# macro xconnect(widget: RootRef; signal: string; p: typed; arg: typed; ignoreArg: bool): untyped
And this is how the error message for a real application looks:
No, I have not seen from the error message that module name prefix was necessary.
I have switched parameter type for handler proc from untyped to typed, as Yardanico told me that typed parameter is necessary to be able to investigate parameter list of handler proc. After changing parameter type to typed, I got that strange error messages and it took me some hours to find out why it was not working with typed parameter. The actual connect macro is this: https://github.com/StefanSalewski/gintro/blob/master/gintro/gimpl.nim#L38 and initially I had the feeling that I did something wrong in the macro. (Araq told me to convert it by using the AST API instead string hacks, I will do that at some time, but it will not help for this issue.) This issue will confuse GTK users for sure.