Use when not if (the type must know by compiler at compile time, not run time):
    
    
    proc makeFont3(fontMessage: int|wFont): wFont {.discardable.}=
        var
            fontTmpMessage: wFont = Font(12, weight=wFontWeightBold)
        
        when (fontMessage is float) or (fontMessage is int) :
            fontTmpMessage = Font(float fontMessage, weight=wFontWeightBold)
        else:
            fontTmpMessage = fontMessage
        
        return fontTmpMessage
    
    
    Run

Reply via email to