Bug 11808 – std.uni.CodepointSet('А', 'Я'+1, 'а', 'я'+1) asserts

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-23T12:23:00Z
Last change time
2014-01-07T11:46:37Z
Keywords
pull
Assigned to
dmitry.olsh
Creator
ilyayaroshenko

Comments

Comment #0 by ilyayaroshenko — 2013-12-23T12:23:32Z
import std.uni; auto set1 = CodepointSet('А', 'Я'+1, 'а', 'я'+1); _________________________ This code asserts because ('Я'+1 == 'а') : this()(uint[] intervals...) in { assert(intervals.length % 2 == 0, "Odd number of interval bounds [a, b)!"); for(uint i=1; i<intervals.length; i++) assert(intervals[i-1] < intervals[i]); //_______________________________!!! } body { data = Uint24Array!(SP)(intervals); //_____________!!!!!!!!!!! I don`t know how manage Uint24Array }
Comment #1 by dmitry.olsh — 2013-12-23T12:55:48Z
(In reply to comment #0) > import std.uni; > > auto set1 = CodepointSet('А', 'Я'+1, 'а', 'я'+1); > { > assert(intervals.length % 2 == 0, "Odd number of interval bounds [a, > b)!"); > for(uint i=1; i<intervals.length; i++) > > > assert(intervals[i-1] < intervals[i]); > //_______________________________!!! Indeed the assumption is that intervals are strictly disjoint and sorted. I'm not sure if it's documented exactly like that but it should be. If it's not known in advance then creating a set per interval and using operator | would work. I'm not sure how much to tweak this constructor, e.g. allow partially overlapped intervals? Allow unordered intervals? auto set2 = CodepointSet('а', 'я'+1, 'А', 'Я'+5);
Comment #2 by ilyayaroshenko — 2013-12-24T05:21:15Z
As user don
Comment #3 by ilyayaroshenko — 2013-12-24T05:38:59Z
I think that we need to allow in constructor: 1. an empty range: [a..a+1) 2. two or more ranges that looks like : [a..b+1) [b+1..c) like in bug example (this case IS NOT overlapping). 3. unordered intervals (user don't know я>Я or Я>я) But do not allow partially overlapped intervals. For overlapped intervals operator "|" should be using. PS Excuse me for my English.
Comment #4 by ilyayaroshenko — 2013-12-24T05:40:28Z
(In reply to comment #1) > (In reply to comment #0) > > import std.uni; > > > > auto set1 = CodepointSet('А', 'Я'+1, 'а', 'я'+1); > > > > { > > assert(intervals.length % 2 == 0, "Odd number of interval bounds [a, > > b)!"); > > for(uint i=1; i<intervals.length; i++) > > > > > > assert(intervals[i-1] < intervals[i]); > > //_______________________________!!! > > Indeed the assumption is that intervals are strictly disjoint and sorted. > I'm not sure if it's documented exactly like that but it should be. > > If it's not known in advance then creating a set per interval and using > operator | would work. > I'm not sure how much to tweak this constructor, e.g. allow partially > overlapped intervals? Allow unordered intervals? > > auto set2 = CodepointSet('а', 'я'+1, 'А', 'Я'+5); I think that we need to allow in constructor: 1. an empty range: [a..a+1) 2. two or more ranges that looks like : [a..b+1) [b+1..c) like in bug example (this case IS NOT overlapping). 3. unordered intervals (user don't know я>Я or Я>я) But do not allow partially overlapped intervals. For overlapped intervals operator "|" should be using. PS Excuse me for my English.
Comment #5 by dmitry.olsh — 2014-01-06T03:12:26Z
Comment #6 by github-bugzilla — 2014-01-07T11:43:40Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/4e5b777432a328160f6f2e29f26564bda52a6d13 fix issue 11808 https://github.com/D-Programming-Language/phobos/commit/b364a2f5f5065a1e843c01516068a27d5c6586b2 Merge pull request #1837 from blackwhale/issue-11808 Fix issue 11808 std.uni.CodepointSet('А', 'Я'+1, 'а', 'я'+1) asserts