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
fix Issue 7300 - std.regex.ShiftOr!dchar.search is broken #462
Conversation
I'm rebasing this. Ehm kills code comments :( |
Anything else on this pull? I'd really like to move this forward. |
Extended, fixed and rebased. |
Looks fine to me – I wonder, though, if |
If documented then we are looking for a better name, something like isTwowayOrder or isTwowayComparator, or whatever. |
Ok, I've settled on just documenting isTwoWayCompatible. Any good ideas for renaming it are still welcome. |
Rework problematic memchr codepath to properly test for end of string. More importantly it's overall cleaner.
It's so simple, and it's been ages as it was broken.
also fix unittest in std.range
makes error messages understandable
fix Issue 7300 - std.regex.ShiftOr!dchar.search is broken
enum isTwoWayCompatible = is(typeof( (){ | ||
T1 e; | ||
T2 v; | ||
return fn(v,e) && fn(e,v); |
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.
The documentation is inconsistent with the example, and both are inconsistent with the implementation.
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 think the example is what documentation states.
Yet, the actual test code is even more restricted.
I'll make a pull to get this in line.
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.
The example also requires that T1 and T2 are default-constructible. You could initialize them with void to fix this.
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.
The trick is ... it doesn't compile with:
T1 e=void;
T2 v=void;
fn(v,e);
fn(e,v);
I believe it has something to do with string predicates.
Like compiler checking "value used before initialized", it works ok for => predicates.
Problem happens with code like this:
import std.range;
void main(){
int[] abc = [1, 2, 3];
auto srange = assumeSorted!"<="(abc);
srange.lowerBound(2);
}
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.
What about
T1 foo();
T2 bar();
fn(foo(), bar());
fn(bar(),foo());
?
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.
Nice one.
#521
Aside from fixing this particular bug in one codepath of ShiftOr this includes