I understand the general use case, but I think this case is very confusing and 
should be flagged. Simplified version: (play in : 
<https://play.nim-lang.org/#ix=2yIv> )
    
    
    type SomeJob = object
      id: string
    
    # one order
    
    proc process1[J](job: J): string = "generic value"
    
    echo process1(SomeJob(id: "1"))
    
    proc process1(job: SomeJob): string = "some value"
    
    echo process1(SomeJob(id: "1"))
    
    # reordered
    
    proc process2[J](job: J): string = "generic value"
    
    proc process2(job: SomeJob): string = "some value"
    
    echo process2(SomeJob(id: "1"))
    
    echo process2(SomeJob(id: "1"))
    
    
    Run

The output produced is:
    
    
    generic value
    some value
    some value
    some value
    
    
    Run

Moving the "echo" past the 2nd proc definition changes the output. I would 
expect at least a warning in this case, because even though the ambiguous match 
IS resolved to the more specific version, as one would expect, both are 
instantiated and used in the same scope, and which one exactly is used in each 
case depends on things like macro expansions etc, which are not self evident.

I would expect reordering of lines to make it compile/not compile because of a 
future reference, but not the output to change.

Furthermore, with the planned code-reordering that would remove the need for 
forward declarations, the meaning of the 1st order in the example may change on 
reordering.

Reply via email to