Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[converter]Separate let and define #61

Open
mattn opened this issue Jul 19, 2017 · 2 comments
Open

[converter]Separate let and define #61

mattn opened this issue Jul 19, 2017 · 2 comments

Comments

@mattn
Copy link
Member

mattn commented Jul 19, 2017

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.

#55

@haya14busa
Copy link
Member

haya14busa commented Jul 19, 2017

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.

@mattn
Copy link
Member Author

mattn commented Jul 19, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants