-
Notifications
You must be signed in to change notification settings - Fork 424
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
chore: add deprecation warnings when casting string/bytes to regex #20944
Conversation
* update .good with deprecation messages for string to regex Signed-off-by: arezaii <ahmad.rezaii@hpe.com>
990cb1e
to
6d3d5c8
Compare
@@ -1444,7 +1444,10 @@ module ChapelBase { | |||
// string to a type. Otherwise, we can't resolve chpl_debug_writeln in | |||
// `range.these` | |||
{ var dummyRange = 1..0; for i in dummyRange {} } | |||
return str:t; | |||
if t:string == "regex(string)" || t:string == "regex(bytes)" then |
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.
how about if t == regex(string) || t == regex(bytes)
?
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.
I attempted to make this change and ran into issues. I added some comments to document the problems encountered and noted that we would prefer to use the type comparison rather than string comparison here.
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.
Looks good to me!
I just have one minor suggestion:
test/regex/bytes/cast.good
Outdated
@@ -1,3 +1,9 @@ | |||
cast.chpl:8: warning: Casting strings to regex is deprecated. Use regex.compile(string) instead. | |||
cast.chpl:9: warning: Casting bytes to regex is deprecated. Use regex.compile(bytes) instead. |
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.
I might remove lines 8-15 from this test since the deprecated cast is still tested in /deprecated/regexTertiary
2d239f5
to
6d3d5c8
Compare
Signed-off-by: arezaii <ahmad.rezaii@hpe.com>
Signed-off-by: arezaii <ahmad.rezaii@hpe.com>
5bee0b5
to
4bab3aa
Compare
This PR marks casts from strings or bytes to regex as deprecated and
suggests using
compile()
fromRegex
module as a replacement untilthrowing initializers are implemented and we can suggest
new regex()
.Updates some test
.good
files to expect the deprecation message.TESTING:
reviewd by @jeremiah-corrado - thanks!