vint icon indicating copy to clipboard operation
vint copied to clipboard

Inline python declared with `exec s:inline_python` results in treating python as error

Open bstaletic opened this issue 9 years ago • 5 comments

While the following vimscript is linted correctly:

python << EOF
import os
EOF

the following, even though equivalen, results in an error on third line:

let s:inline_python = 'python << EOF'
exec s:inline_python
import os
EOF

This way of declaring inline python can be useful when s:inline_python has different value depending on the python interpreter that should be used.

bstaletic avatar Dec 05 '16 17:12 bstaletic

@bstaletic Thanks for the report.

I want to see the error occurred. Could you show me the error message, please?

Kuniwak avatar Dec 06 '16 01:12 Kuniwak

@Kuniwak

File producing the error, named test.vim:

let s:inline_python = 'python << EOF'
exec s:inline_python
import os
EOF

Vint command used: vint -f '{file_path}:{line_number}:{column_number}:{severity}:{description} ({policy_name})' -s test.vim Error reported by vin: test.vim:3:1:error:E492: Not an editor command: import os (SyntaxError)

Note: This need not be an import line that causes the error, but any line that is valid python, but invalid vimscript.

bstaletic avatar Dec 06 '16 08:12 bstaletic

I confirmed the problem. But I think this cause is in vim-vimlparse.

vint._bundles.vimlparser.VimLParserException: vimlparser: E492: Not an editor command: import os: line 3 col 1

I reported this issue by https://github.com/ynkdir/vim-vimlparser/issues/33

Kuniwak avatar Dec 07 '16 01:12 Kuniwak

Just for reference: test/fixture/ast/inline_python.vim has been added (probably accidentally) in 9816a31.

blueyed avatar Apr 17 '18 08:04 blueyed

It would be nice if vint would allow to ignore whole sections of a file completely (i.e. exclude it from having it parsed/handled by vimlparser in the first place).

blueyed avatar Apr 17 '18 08:04 blueyed