Hello awesome people,

I'm a newbie to Nim, and trying to rewrite my game engine to it to learn. I've 
encountered a strange problem with template and untyped argument. I'm not sure 
what exactly is going on. It feels like compiler error really, as the two 
examples bellow are only different on wheteher I pass batch: var BatchArg to 
the function. Once I do, the template's untyped argument is being checked and 
results in undeclared identifier.

However it must be the BatchArg thing, because if I pass just batch: var Batch 
it works. But I don't know how it relates to the template inside that is 
completely independent on that argument.

Any hints appreciated.
    
    
    type Quad* = object
        a*: int
    
    type Batch* = object
        a*: int
    
    type BatchArg = Batch or ref Batch
    
    # Works
    proc testB*() =
        var quad = Quad()
        template attrib(member: untyped) =
            echo quad.member
        
        attrib(a)
    
    testB()
    
    # Doesn't work
    proc testA*(batch: var BatchArg) =
        var quad = Quad()
        template attrib(member: untyped) =
            echo quad.member
        
        attrib(a) # << Error: undeclared identifier: 'a'
    
    var batch = Batch()
    testA(batch)
    

Reply via email to