-
Notifications
You must be signed in to change notification settings - Fork 312
fix: handle operators in constructor default arguments #449
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: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3943,14 +3943,15 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum, nesting_state, | |
| else: | ||
| constructor_args = explicit_constructor_match.group(2).split(",") | ||
|
|
||
| # collapse arguments so that commas in template parameter lists and function | ||
| # argument parameter lists don't split arguments in two | ||
| # Collapse commas inside template and function parameter lists. | ||
| i = 0 | ||
| while i < len(constructor_args): | ||
| constructor_arg = constructor_args[i] | ||
| while constructor_arg.count("<") > constructor_arg.count(">") or constructor_arg.count( | ||
| "(" | ||
| ) > constructor_arg.count(")"): | ||
| # Ignore `<`-prefixed operators when balancing template brackets. | ||
| while i + 1 < len(constructor_args) and ( | ||
| re.sub(r"<<=?|<=", "", constructor_arg).count("<") > constructor_arg.count(">") | ||
| or constructor_arg.count("(") > constructor_arg.count(")") | ||
|
Comment on lines
+3952
to
+3953
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems very inefficient. We were already using .count to do four optimized single-character passes, and now we add a regex pass on top of that. Not to mention we're sort of simulating regex with the consuming ( |
||
| ): | ||
| constructor_arg += "," + constructor_args[i + 1] | ||
| del constructor_args[i + 1] | ||
| constructor_args[i] = constructor_arg | ||
|
|
||
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 there a reason for this change?