[Fix][TVMScript] Fix LetStmt
printing logic
#13900
Merged
Add this suggestion to a batch that can be applied as a single commit.
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.
Add this suggestion to a batch that can be applied as a single commit.
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.
Suggestion cannot be applied right now. Please check back later.
This PR is the bug fix reported in #13892. Initially, we mix the logic of
LetStmt
docsifying method with and without concise scoping. For example, inx
in theLetStmt
works as a right value, while inx
in theLetStmt
works as a left value as result.Our old logic mixed them together to generate the wrong code for the first case.
Meanwhile, during the fix, we found another bug in concise scoping check. For example, we have
here we should not output
becase this will define a new
y_1: int32 = 0
indeed, due the the variable shadowing logic of the parser, which is different from they
we define and refer to.Our concise scoping
v: ... = ...
should launch if and only if thev
is never defined before.Otherwise, we use
with T.let(v, ...):
instead.