I already [gave an answer](https://forum.nim-lang.org/t/6161#38066) in your 
previous thread and people have answered already, but I'll give an answer that 
shows more info in the error message. You don't need to import `macros` for any 
of this, `astToStr` and `typeof` are in the system module.
    
    
    template `==`(a: Real, b: untyped): bool =
      when typeof(b) is not float:
        {.error: "Second param " & astToStr(b) & " of == with Real is not a 
float, but is " & $typeof(b).}
      a.val == b
    
    template `==`(a: untyped, b: Real): bool =
      when typeof(a) is not float:
        {.error: "First param " & astToStr(b) & " of == with Real is not a 
float, but is " & $typeof(b).}
      a == b.val
    
    
    Run

Reply via email to