The following program does not compile:
    
    
    proc addoneb(a : distinct string, b : distinct string) :  distinct string =
      when typeof(a) is distinct string :
          let v = a & b
          result = v
      else :
          result = cast[distinct string]("")
    
    proc run() =
        let a = "alice"
        let b = "bob"
        let c = addone(a,b)
        echo cast[string](c)
    
    run()
    
    
    
    
    
    Run

and I got:
    
    
    Error: type mismatch:
     got 'distinct string' for 'cast[distinct string]("")' [string declared in 
/home/gsixte/.choosenim/toolchains/nim-1.6.2/lib/system.nim(34, 3)]
     but expected 'distinct string' [string declared in 
/home/gsixte/.choosenim/toolchains/nim-1.6.2/lib/system.nim(34, 3)]
    
    
    
    Run

So, the compiler complains like: "I ordered a coffee and you brought me a 
coffee". Hard to understand. 

Reply via email to