-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add type restrictions to regex directory #16066
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
base: master
Are you sure you want to change the base?
Conversation
This is the output of compiling [cr-source-typer](https://github.com/Vici37/cr-source-typer) and running it with the below incantation: ``` CRYSTAL_PATH="./src" ./typer spec/std_spec.cr \ --error-trace --exclude src/crystal/ \ --stats --progress \ --union-size-threshold 2 \ --ignore-private-defs \ src/regex ``` This is related to crystal-lang#15682 .
# re.match("sledding") # => Regex::MatchData("sledding") | ||
# ``` | ||
def +(other) : Regex | ||
def +(other : Regex) : Regex |
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.
That's what Regex.union
accepts:
def +(other : Regex) : Regex | |
def +(other : Regex | String) : Regex |
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 seems a bit odd though. I don't think the String
overload is much useful. Maybe we should deprecate that?
For this PR it might just be best to remove the type restriction. We can follow up with a dedicated change.
@[Deprecated("Use the overload with `Regex::MatchOptions` instead.")] | ||
def match(str, pos = 0, *, options) : MatchData? | ||
def match(str : String, pos : Int32 = 0, *, options : Regex::Options) : MatchData? |
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.
Is it worth adding type restrictions to a deprecated methods?
ditto elsewhere
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.
That's a good catch. Probably not.
However, since it's already there...
This is the output of compiling cr-source-typer and running it with the below incantation:
This is related to #15682 .