vint icon indicating copy to clipboard operation
vint copied to clipboard

Undefined variable when used within braces

Open natemaia opened this issue 7 years ago • 0 comments

Consider the following snippet

let my_fallbacks_dict = { 'val1': 1, 'val2': 2 }

for val in keys(my_fallbacks_dict)
    let s:my_{val} = exists('g:my_'.val) ? g:my_{val} : my_fallbacks_dict[val]
endfor

" vint says s:my_val1 and s:my_val2 are undefined, but they are defined
let mylist = ['s:my_val1 : '.s:my_val1, 's:my_val2 : '.s:my_val2]

Would it be possible to 'expand' the variable val when used as a name for another variable? eg.

s:my_{var} = ....

becomes

s:my_val1 = ....

This would avoid the need to have " vint: -ProhibitUsingUndeclaredVariable at the top of my file when using the above code to define optional variables.

Cheers

natemaia avatar Nov 03 '18 22:11 natemaia