fix: closing brace should not be a part of variable#10485
Merged
Conversation
shreemaan-abhishek
marked this pull request as draft
November 14, 2023 01:02
shreemaan-abhishek
marked this pull request as ready for review
November 14, 2023 03:12
Sn0rt
approved these changes
Nov 14, 2023
Contributor
|
please make the ci pass |
Contributor
Author
|
done |
dramenk
approved these changes
Nov 14, 2023
Comment on lines
+299
to
+304
| local v = _ctx[m[1]] | ||
| local i = 1 | ||
| -- if first capture's first char is "{" evaluate the second capture | ||
| if m[1]:byte(1) == 123 then | ||
| i = 2 | ||
| end | ||
| local v = _ctx[m[i]] |
Contributor
There was a problem hiding this comment.
Why do you add this? we don't need this block to resolve this problem
Contributor
Author
There was a problem hiding this comment.
this was to fix other test case failures. For example when var = ${alpha}, m[1] = {alpha} and m[2] = alpha. Only m[2] can be evaluated no m[1].
| local v = _ctx[m[1]] | ||
| local i = 1 | ||
| -- if first capture's first char is "{" evaluate the second capture | ||
| if m[1]:byte(1) == 123 then |
Contributor
There was a problem hiding this comment.
I think you can optimise this judgement, like
local variable = m[2] or m[3]
local v = _ctx[variable]
Contributor
Author
There was a problem hiding this comment.
it works
juststillthinking
approved these changes
Nov 22, 2023
AlinsRan
approved these changes
Nov 24, 2023
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
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.
Description
Current regex for evaluating variables like:
$var,${var}, etc. would also match$var}including the closing brace. This has been fixed.Fixes #10478
Checklist