Two arrays of the same size and element type but with different index 
boundaries seem to be distinct types for the purpose of (polymorphic) proc 
definitions, so this compiles: 
    
    
    proc p(a: array[10, int]) = discard
    proc p(a: array[-1 .. 8, int]) = discard
    

but they seem to be treated as identical when attempt to call this proc is 
made, so this: 
    
    
    var a: array[10, int]
    p(a)
    

fails to compile with the following error message: 
    
    
    test.nim(6, 2) Error: ambiguous call; both test.p(a: array[0..9, 
int])[declared in test.nim(1, 5)] and test.p(a: array[-1..8, int])[declared in 
test.nim(2, 5)] match for: (array[0..9, int])
    

Nim compiler version: 
    
    
    > nim -v
    Nim Compiler Version 0.17.2 (2017-09-07) [Windows: amd64]
    Copyright (c) 2006-2017 by Andreas Rumpf
    
    git hash: 811fbdafd958443ddac98ad58c77245860b38620
    active boot switches: -d:release
    

I understand that this example may seem rather synthetic (though I actually run 
into this while testing an idea of providing two different indexing schemes for 
C-array used in some external C DLL call), but the situation when you can 
declare something that you cannot later call looks rather strange and 
inconsistent.

Reply via email to