So today i was messing around with Generic types and I found something that I 
think would be considered "Undefined behavior". I thought I would just share it 
here in case anyone else gets the same idea.
    
    
    type
      Gen[val:static[auto]] = auto
      true_t = Gen[true]
    
    var a:true_t = "hello"
    var b:true_t = 10
    proc c(a:true_t):void =
      echo a
    c(a)
    c(b)
    
    
    Run

**the output here is understandable**
    
    
     Hint: system [Processing]
    Hint: test [Processing]
    Error: internal error: (filename: "semtypes.nim", line: 908)
    
    No stack traceback available
    To create a stacktrace, rerun compilation with ./koch temp c <file>
    
    
    Run

I would like to explain why I think this happens. I think that the error occurs 
because when declaring Gen[ **whatever this may be** ] I actually turn 
**true_t** into two distinct types, and when executing the _proc_ **c** it 
would probably expect the type **string** because that would be what the first 
actual definition of the _proc_ does, or maybe because it is an ambiguous proc, 
though it doesn't really seem to catch onto that and just crashes.

It made me laugh a little so I thought I would share.

**Thanks for reading**

Reply via email to