vint
vint copied to clipboard
Undefined variable when used within braces
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