-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
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
More rules for strings
module functions
#96
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sgtm
// 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)`)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Where(m["n"].Const && m["n"].Text.Matches(`(\-[0-9]+|0)`))
+ Where(m["n"].Value.Int() <= 0)
I like the idea of testing with local |
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 <[email protected]>
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 <[email protected]>
This is a copy of #94 that doesn't depend on (but conflicts with) #93