@jibal The error you're receiving is because you've named the loop variable the
same as the injected variable, which overrides the injected variable. This
works:
template t(body: untyped) =
proc bod(a: int) =
let x {.inject.} = a
body
for i in [1, 2, 3, 4]:
bod(i)
t:
echo x
Run
- bizarre name clash with template jibal
- Re: bizarre name clash with template jibal
- Re: bizarre name clash with template cblake
- Re: bizarre name clash with template jyapayne
- Re: bizarre name clash with template jibal
- Re: bizarre name clash with template jibal
- Re: bizarre name clash with template jibal
- Re: bizarre name clash with templat... cblake
- Re: bizarre name clash with templat... jyapayne
- Re: bizarre name clash with templat... jibal
- Re: bizarre name clash with templat... solo989
- Re: bizarre name clash with templat... jibal
- Re: bizarre name clash with templat... cblake
- Re: bizarre name clash with templat... Araq
