We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
If a script-local variable is defined with const, it is not recognized as a variable definition, e.g. a file test.vim with the content
test.vim
const s:aa = 1 echomsg s:aa
yields as output of vint -w test.vim
vint -w test.vim
test.vim:1:7: Undefined variable: s:aa (see :help E738) test.vim:2:9: Undefined variable: s:aa (see :help E738)
Replacing const with let lets the warning go away. Likewise using aa instead of s:aa as variable name solves it, too.
const
let
aa
s:aa
My guess is that const x = y is not recognised as a definition. I have no clue how vint works but if I add the following the warning vanishes:
const x = y
--- a/vint/ast/plugin/scope_plugin/identifier_classifier.py +++ b/vint/ast/plugin/scope_plugin/identifier_classifier.py @@ -26,6 +26,7 @@ DECLARING_IDENTIFIERS = 'VINT:declaring_identifiers' DeclarativeNodeTypes = { NodeType.LET: True, + NodeType.CONST: True, NodeType.FUNCTION: True, NodeType.FOR: True, NodeType.EXCMD: True, @@ -463,6 +464,18 @@ class IdentifierClassifier(object): ) + def _enter_const_node(self, const_node, is_on_lambda_body, is_on_lambda_str): + # Only "=" operator can be used as declaration. + if const_node['op'] != '=': + return + + self._enter_assignment_node( + const_node, + is_on_lambda_str=is_on_lambda_str, + is_on_lambda_body=is_on_lambda_body, + ) + + def _enter_for_node(self, for_node, is_on_lambda_body, is_on_lambda_str): self._enter_assignment_node( for_node, @@ -526,6 +539,13 @@ class IdentifierClassifier(object): is_on_lambda_body=is_on_lambda_body, ) + elif node_type is NodeType.CONST: + self._enter_const_node( + node, + is_on_lambda_str=is_on_lambda_str, + is_on_lambda_body=is_on_lambda_body, + ) + elif node_type is NodeType.FOR: self._enter_for_node( node,
Remark: _enter_const_node() is exactly the same as _enter_let_node() (except a variable name).
_enter_const_node()
_enter_let_node()
Note: There is also a DeclarativeNodeTypes in vint/ast/plugin/scope_plugin/scope_linker.py but that seems unused. So maybe that should be removed.
DeclarativeNodeTypes
vint/ast/plugin/scope_plugin/scope_linker.py
The text was updated successfully, but these errors were encountered:
No branches or pull requests
If a script-local variable is defined with const, it is not recognized as a variable definition, e.g. a file
test.vim
with the contentyields as output of
vint -w test.vim
Replacing
const
withlet
lets the warning go away. Likewise usingaa
instead ofs:aa
as variable name solves it, too.My guess is that
const x = y
is not recognised as a definition.I have no clue how vint works but if I add the following the warning vanishes:
Remark:
_enter_const_node()
is exactly the same as_enter_let_node()
(except a variable name).
Note: There is also a
DeclarativeNodeTypes
invint/ast/plugin/scope_plugin/scope_linker.py
but that seems unused. So maybe that should be removed.The text was updated successfully, but these errors were encountered: