I have a procedure which should accept two units(absolute width and width 
relative to the parent widget). For this purpose I created two distinct types 
and a typeclass which contains both: 
    
    
    type
       UIAbsLength = distinct float32
       UIRelLength = distinct float32
       
       UILength = UIAbsLength|UIRelLength
    

Then I created a procedure which accepts both types and has a default 
value(this is an Immediate Gui, were widgets are instatiated with a single 
call, so default values are really handy here): 
    
    
    proc button*(self: UISystem, buttonLabel = none(string), width, height: 
UILength = UIAbsLength(0)) =
       when width is UIAbsLength:
          discard
       elif height is UIAbsLength:
          discard
    

Now the problem arrives, that once I call the procedure with `UIRelLength` the 
compiler throws an error(`Error: type mismatch: got (UIAbsLength) but expected 
'UIRelLength = distinct float32'`)

Should this work at all? Or could this be done in some other way? Or is it 
maybe a compiler bug?

Reply via email to