It's like something breaks under a certain combination of factors

[download 
sources](https://drive.google.com/file/d/1X_uas69a2vU-XW7IYN5IKbJ7bB0fr18p/view?usp=sharing)
    
    
    # base.nim
    type Base*[T] = object
    func `value=`*(base: Base, v: int) = discard
    
    
    Run
    
    
    # foo.nim
    import base
    export base
    const f* = Base[int]()
    
    
    Run
    
    
    # misc.nim
    import foo
    proc setValue*[T](a: T) =
      f.value = a
    
    
    Run
    
    
    # main.nim
    import misc
    setValue(1)
    
    
    Run
    
    
    $ nim c main.nim
    ...
    misc.nim(2, 8) Warning: imported and not used: 'foo' [UnusedImport]
    main.nim(3, 9) template/generic instantiation of `setValue` from here
    misc.nim(4, 11) Error: attempting to call undeclared routine: 'value='
    
    
    Run

If you change `f.value = a` to `f.`value=`(a)`
    
    
    # misc.nim
    import foo
    proc setValue*[T](a: T) =
      f.`value=`(a)
    
    
    Run

then it compiles, but continues to output the wrong warning: 
    
    
    misc.nim(2, 8) Warning: imported and not used: 'foo' [UnusedImport]
    
    
    Run

If you make ' setValue` a regular function instead of a generic, then 
everything will work as it should. 
    
    
    # misc.nim
    import foo
    proc setValue*(a: int) =
      f.value = a
    
    
    Run

Reply via email to