Skip to content
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 Bugzilla Issue 24637 -- [REG 2.104] Cannot insert const/immutable elements into DList #9042

Open
wants to merge 30 commits into
base: stable
Choose a base branch
from
Open
Changes from 3 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
55a9559
Fix Bugzilla Issue 24637 -- [REG 2.104] Cannot insert const/immutable…
RubyTheRoobster Aug 3, 2024
c964787
Remove some trailing whitespace.
RubyTheRoobster Aug 3, 2024
2ff13d5
Fix Style Violations
RubyTheRoobster Aug 3, 2024
ea8650a
Fix whitespace (again)
RubyTheRoobster Aug 4, 2024
b5afd4d
Add Newline
RubyTheRoobster Aug 6, 2024
cba26e4
Remove unecessary variable
RubyTheRoobster Aug 7, 2024
8ec19b0
Make test case stronger and remove useless contructor overload
RubyTheRoobster Aug 9, 2024
20e722c
Fix whitepsace
RubyTheRoobster Aug 9, 2024
6eedf00
Remove std.conv import from quickSortImpl
0-v-0 Jun 22, 2024
3c360d5
Move `std.math.exponential.pow` implementation outside template (#9019)
dkorpel Jul 3, 2024
4199740
fix ddoc blunders
jtbx Jul 7, 2024
1ec49dd
fix minor spelling mistake
jtbx Jul 7, 2024
eb14aa3
replace dead links
jtbx Jul 14, 2024
c740a4c
std.stdio: fdopen is a POSIX library function
jtbx Jul 14, 2024
fb1d5da
std.json: Document `opEquals` (#8975)
dkorpel Jul 19, 2024
9e97195
Expand `goo.gl` links that may break
ntrel Jul 19, 2024
811e8eb
Fix Lockstep attribute limitation
Jul 15, 2024
946735f
Address style errors
Jul 15, 2024
e261862
Fix problems with reverse
Jul 15, 2024
4fd0bd2
Address style errors
Jul 15, 2024
b7d5fc0
DEPRECATED_2.107 code removed (#9028)
denizzzka Jul 23, 2024
c2e160f
Adds check bounds of year to std.datetime.date.Date
denizzzka Jul 17, 2024
51a60bb
Bugzilla 23300 - add testcase for std.array on scope InputRange
dkorpel Jul 19, 2024
b0ee848
Fix Bugzilla 24685 - std.stdio.File.rawRead allows reading raw pointe…
ntrel Jul 26, 2024
c3a867c
Fix Bugzilla 14138 - std.parallelism.task breaks @safety (#9033)
ntrel Jul 28, 2024
250553b
Fix Bugzilla 15315 - can break immutable with std.algorithm.move (#9032)
ntrel Jul 28, 2024
4badf4b
Fix Bugzilla 20870 - std.outbuffer.printf is trusted (#9037)
ntrel Jul 31, 2024
3cc69b0
Fix Bugzilla 20872 - std.array.assocArray trusts user-provided 'front…
ntrel Jul 31, 2024
8b2a6e2
Silence buildkite style failure on std.range
dkorpel Jul 31, 2024
a7885a1
Fix Bugzilla 22293: opCast!bool for Nullable (#9039)
pbackus Aug 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions std/container/dlist.d
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ Implements a doubly-linked list.
struct DList(T)
{
import std.range : Take;
import std.traits : isMutable;

/*
A Node with a Payload. A PayNode.
Expand All @@ -204,6 +205,15 @@ struct DList(T)
this._payload = move(_payload);
}

this (U)(BaseNode _base, U _payload) if(is(U == const(T)) ^ is(U == immutable(T)))
RubyTheRoobster marked this conversation as resolved.
Show resolved Hide resolved
{
import std.algorithm.mutation : move;

this._base = _base;
temp = cast(T)_payload;
RubyTheRoobster marked this conversation as resolved.
Show resolved Hide resolved
this._payload = move(temp);
}

inout(BaseNode)* asBaseNode() inout @trusted
{
return &_base;
Expand All @@ -219,8 +229,10 @@ struct DList(T)
static BaseNode* createNode(Stuff)(auto ref Stuff arg, BaseNode* prev = null, BaseNode* next = null)
{
import std.algorithm.mutation : move;

return (new PayNode(BaseNode(prev, next), move(arg))).asBaseNode();
static if (isMutable!Stuff)
return (new PayNode(BaseNode(prev, next), move(arg))).asBaseNode();
else
return (new PayNode(BaseNode(prev, next), arg)).asBaseNode();
}

void initialize() nothrow @safe pure
Expand Down Expand Up @@ -1148,3 +1160,17 @@ private:
list.removeFront();
assert(list[].walkLength == 0);
}

// Regression https://issues.dlang.org/show_bug.cgi?id=24637
@safe unittest
{
import std.algorithm.comparison : equal;
DList!int D;

D.insert(1);
assert(D[].equal([1]));

const c = 3;
D.insert(c);
assert(D[].equal([1, 3]));
}
RubyTheRoobster marked this conversation as resolved.
Show resolved Hide resolved
Loading