More rules for strings module functions#96
Open
orsinium wants to merge 3 commits intoquasilyte:masterfrom
Open
More rules for strings module functions#96orsinium wants to merge 3 commits intoquasilyte:masterfrom
strings module functions#96orsinium wants to merge 3 commits intoquasilyte:masterfrom
Conversation
quasilyte
reviewed
Oct 30, 2020
| // The special case is zero. Zero does nothing, so it's a bug, so we replace it too. | ||
| // Everything else is for consistency. | ||
| m.Match(`strings.Replace($s, $d, $w, $n)`). | ||
| Where(m["n"].Const && m["n"].Text.Matches(`(\-[0-9]+|0)`)). |
Owner
There was a problem hiding this comment.
It looks like if we had a way to const-fold expressions into int we could just check it like:
m["n"].ConstValue.Int() <= 0
It's not hard to implement, actually.
What do you think?
Owner
There was a problem hiding this comment.
- Where(m["n"].Const && m["n"].Text.Matches(`(\-[0-9]+|0)`))
+ Where(m["n"].Value.Int() <= 0)
Owner
|
I like the idea of testing with local |
quasilyte
added a commit
that referenced
this pull request
Oct 31, 2020
Added Value expression field that can be used to check the submatch value. Since `go/types` has some const-folding out-of-the-box, we get it too. Right now only `int` value types are supported, but we could extend the set of types later. This is a proof-of-concept that can be useful in #96. Signed-off-by: Iskander Sharipov <quasilyte@gmail.com>
quasilyte
added a commit
that referenced
this pull request
Oct 31, 2020
Added Value expression field that can be used to check the submatch value. Since `go/types` has some const-folding out-of-the-box, we get it too. Right now only `int` value types are supported, but we could extend the set of types later. This is a proof-of-concept that can be useful in #96. Signed-off-by: Iskander Sharipov <quasilyte@gmail.com>
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.
This is a copy of #94 that doesn't depend on (but conflicts with) #93