{{ message }}
bpo-40334: Correctly generate C parser when assigned var is None#20296
Merged
pablogsal merged 3 commits intoMay 21, 2020
Merged
bpo-40334: Correctly generate C parser when assigned var is None#20296pablogsal merged 3 commits into
pablogsal merged 3 commits into
Conversation
When there are 2 negative lookaheads in a same rule, let's say
`!"(" blabla "," !")"`, there will the 2 `FunctionCall`'s where
assigned value is None. Currently when the `add_var` is called
the first one will be ignored (since it will be returned as same
from dedupe because there aren't any `None` named variables in
locals, but when the second lookahead's var is sent to dedupe it
will be returned as `None_1` and this wont be ignored by the
declaration generator in the `visit_Alt`. This patch adds an explicit
check to `add_var` to distinguish whether if there is a variable or not.
Member
|
Could you add a test? |
Sorry, something went wrong.
Member
Author
|
I couldnt find the suitable place to add test, would you give me a hint about it? |
Sorry, something went wrong.
Member
Sorry, something went wrong.
Member
|
or alternatively https://github.com/python/cpython/blob/master/Lib/test/test_peg_generator/test_c_parser.py if you cannot reproduce it in the Python version. |
Sorry, something went wrong.
Member
Author
|
I dont know if this test is suitable, but I couldn't find a better way to test this. |
Sorry, something went wrong.
Member
|
Also, why mypy has not catched this? |
Sorry, something went wrong.
pablogsal
reviewed
May 21, 2020
This reverts commit 5440280.
pablogsal
approved these changes
May 21, 2020
arturoescaip
pushed a commit
to arturoescaip/cpython
that referenced
this pull request
May 24, 2020
…honGH-20296) When there are 2 negative lookaheads in the same rule, let's say `!"(" blabla "," !")"`, there will the 2 `FunctionCall`'s where assigned value is None. Currently when the `add_var` is called the first one will be ignored but when the second lookahead's var is sent to dedupe it will be returned as `None_1` and this won't be ignored by the declaration generator in the `visit_Alt`. This patch adds an explicit check to `add_var` to distinguish whether if there is a variable or not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.
When there are 2 negative lookaheads in a same rule, let's say
!"(" blabla "," !")", there will the 2FunctionCall's whereassigned value is None. Currently when the
add_varis calledthe first one will be ignored (since it will be returned as same
from dedupe because there aren't any
Nonenamed variables inlocals, but when the second lookahead's var is sent to dedupe it
will be returned as
None_1and this wont be ignored by thedeclaration generator in the
visit_Alt. This patch adds an explicitcheck to
add_varto distinguish whether if there is a variable or not.https://bugs.python.org/issue40334