vim-vimlparser
vim-vimlparser copied to clipboard
[converter]Separate let and define
function! s:foo()
if v:true
let s = 1
else
let s = 2
endif
endfunction
This script is translated to
(function (s:foo)
(if v:true
(let = s 1)
else
(let = s 2)))
But this should be
(function (s:foo)
(let = s 0) ;;; define
(if v:true
(let = s 1) ;;; let
else
(let = s 2))) ;;; let
This can be fixes with traversing let
nodes, maybe.
https://github.com/vim-jp/vim-vimlparser/pull/55
Do you mean you want to add other translater or provide traversing utilities for translaters?
This is not needed for VimL->S-like-expression / Python / JavaScript translators. I'm not sure this is the problem of this repository.
But this should be ...
I don't think so. Translater should translate the script as same as possible basically. (except it's some optimization purpose or some other useful purpose.
Yes, I didn't consider exists()
.
function! s:foo()
if v:true
let s = 1
endif
if exists('s')
" blah blah
endif
endfunction
We can't translate this into js since script author might expect this behavior as is. So we can't prepend define variable
.