[Issue 20876] DMD gives out not so helpful compile error
https://issues.dlang.org/show_bug.cgi?id=20876 RazvanN changed: What|Removed |Added CC||razvan.nitu1...@gmail.com --- Comment #4 from RazvanN --- (In reply to moonlightsentinel from comment #3) > Reduced test case: > > struct Array > { > void opSliceAssign(Foo) {} > void opSliceAssign(Foo, size_t, size_t) {} > } > > struct Foo { > Bar _bar; > } > > struct Bar { > version (Bug) > this(ref Bar) { } > else > this(Bar) { } > } > > void main() > { > Foo foo; > Array arr; > arr[] = foo; > } The fundamental problem is that when the compiler sees a struct that has a field that defines a copy constructor it generates an inout copy construct that has the form: this(ref inout(T)) inout; In this specific situation it creates such a copy constructor for Foo: this(ref inout(Foo) p) inout { this._bar = p._bar; } This generated copy constructor fails to compile because `this._bar = p._bar` gets rewritten to `this._bar.__copyCtor(p._bar)` and this failst because `this(ref Bar)` cannot be called with argument types `(ref inout(Bar)) inout`. Therefore it will be annotated with disable. When I implemented the copy constructor I initially proposed this scheme having in mind that if you want to upgrade your postblits to copy constructors, then you can simply replace `this(this)` with `this(ref inout typeof(this) p) inout`. That way the generation scheme for postblits would work kind of the same and the code would not be affected. However, pondering upon it some more I thought of a superior generation scheme [1]. The latter would make this error go away and the code would compile, however Walter opposed it so now we are stuck with inout constructors. So, to conclude, by the current language rules the error is correct. The fix in this situation would be to annotate the copy constructor of Bar with `inout`: this(ref inout(Bar)) inout . That will make the code to compile. But I agree that the error could be improved. [1] https://github.com/dlang/DIPs/pull/129/commits/7815bc3fc49dd9f1a2195f871f3f6afe6c9d6c8b#diff-7f9578c76cc7367ecc56acfce679fc4bR675 --
[Issue 19525] Duration is not usable with zero-arg std.algorithm.sum
https://issues.dlang.org/show_bug.cgi?id=19525 Dlang Bot changed: What|Removed |Added Status|REOPENED|RESOLVED Resolution|--- |FIXED --- Comment #5 from Dlang Bot --- dlang/phobos pull request #7504 "Fix issue 19525 - Duration is not usable with zero-arg std.algorithm.sum" was merged into master: - fd59b6a92e8c2a9e56db0c788f6b40f7d930aef0 by Biotronic: Fix issue 19525 https://github.com/dlang/phobos/pull/7504 --
[Issue 20876] DMD gives out not so helpful compile error
https://issues.dlang.org/show_bug.cgi?id=20876 --- Comment #3 from moonlightsenti...@disroot.org --- Reduced test case: struct Array { void opSliceAssign(Foo) {} void opSliceAssign(Foo, size_t, size_t) {} } struct Foo { Bar _bar; } struct Bar { version (Bug) this(ref Bar) { } else this(Bar) { } } void main() { Foo foo; Array arr; arr[] = foo; } --
[Issue 20875] [REG2.087.1] Enum template specialization ignored
https://issues.dlang.org/show_bug.cgi?id=20875 Dlang Bot changed: What|Removed |Added Keywords||pull --- Comment #1 from Dlang Bot --- @NilsLankila created dlang/dmd pull request #11193 "fix issue 20875 - specialization ignored for template alias param use…" fixing this issue: - fix issue 20875 - specialization ignored for template alias param used with type The "regression" was introduced by https://github.com/dlang/dmd/pull/9769. The problem was actually more than the check for the template parameter specialization was not done yet, so this is more a new case of "accept invalid" than a "regression". This new check consists into verifying that a type passed to a template alias parameter implicitly converts to the one used as template specialization. In addition a new error is introduced, in case where the specialization would not be a type, since checking for implicit convertion makes no sense anymore. https://github.com/dlang/dmd/pull/11193 --
[Issue 19525] Duration is not usable with zero-arg std.algorithm.sum
https://issues.dlang.org/show_bug.cgi?id=19525 Dlang Bot changed: What|Removed |Added Keywords||pull --- Comment #4 from Dlang Bot --- @Biotronic created dlang/phobos pull request #7504 "Fix issue 19525 - Duration is not usable with zero-arg std.algorithm.sum" fixing this issue: - Fix issue 19525 https://github.com/dlang/phobos/pull/7504 --
[Issue 20874] std.json.assign requires '@safe' and 'pure'
https://issues.dlang.org/show_bug.cgi?id=20874 Dlang Bot changed: What|Removed |Added Keywords||pull --- Comment #2 from Dlang Bot --- @MoonlightSentinel created dlang/phobos pull request #7503 "Fix Issue 20874 - std.json.assign requires '@safe' and 'pure'" fixing this issue: - Fix Issue 20874 - std.json.assign requires '@safe' and 'pure' https://github.com/dlang/phobos/pull/7503 --
[Issue 20874] std.json.assign requires '@safe' and 'pure'
https://issues.dlang.org/show_bug.cgi?id=20874 --- Comment #1 from moonlightsenti...@disroot.org --- Also applies to pure for some methods --
[Issue 20874] std.json.assign requires '@safe' and 'pure'
https://issues.dlang.org/show_bug.cgi?id=20874 moonlightsenti...@disroot.org changed: What|Removed |Added CC||moonlightsentinel@disroot.o ||rg Summary|std.json.assign requires|std.json.assign requires |'@safe' |'@safe' and 'pure' --
[Issue 20876] DMD gives out not so helpful compile error
https://issues.dlang.org/show_bug.cgi?id=20876 kinke changed: What|Removed |Added CC||ki...@gmx.net --- Comment #2 from kinke --- (In reply to moonlightsentinel from comment #1) > Digger blames the introduction of copy constructors: Yes; it works with postblit and a by-value copy ctor, but doesn't with the used by-ref copy ctor. --
[Issue 20876] DMD gives out not so helpful compile error
https://issues.dlang.org/show_bug.cgi?id=20876 moonlightsenti...@disroot.org changed: What|Removed |Added CC||moonlightsentinel@disroot.o ||rg --- Comment #1 from moonlightsenti...@disroot.org --- Digger blames the introduction of copy constructors: commit f9cbf699c0fa07892137d477fbe1ea197c8d0cbe Author: Andrei Alexandrescu Date: Wed Mar 27 21:21:33 2019 -0400 dmd: Merge pull request #8688 from RazvanN7/CpCtor https://github.com/dlang/dmd/pull/8688 Implement copy constructor --
[Issue 20876] New: DMD gives out not so helpful compile error
https://issues.dlang.org/show_bug.cgi?id=20876 Issue ID: 20876 Summary: DMD gives out not so helpful compile error Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: regression Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: pun...@coverify.org Created attachment 1793 --> https://issues.dlang.org/attachment.cgi?id=1793=edit test.d Compiles without error with dmd-2.085. With the dmd nightly build I get: $ dmd -c test.d /tmp/dmd2/linux/bin64/../../src/phobos/std/container/array.d(208): Error: none of the overloads of opSliceAssign are callable using argument types (Foo, ulong, ulong), candidates are: /tmp/dmd2/linux/bin64/../../src/phobos/std/container/array.d(724): std.container.array.Array!(Foo).Array.opSliceAssign(Foo value) /tmp/dmd2/linux/bin64/../../src/phobos/std/container/array.d(731): std.container.array.Array!(Foo).Array.opSliceAssign(Foo value, ulong i, ulong j) /tmp/dmd2/linux/bin64/../../src/phobos/std/container/array.d(215): Error: none of the overloads of opSliceAssign are callable using argument types (Foo, ulong, ulong), candidates are: /tmp/dmd2/linux/bin64/../../src/phobos/std/container/array.d(724): std.container.array.Array!(Foo).Array.opSliceAssign(Foo value) /tmp/dmd2/linux/bin64/../../src/phobos/std/container/array.d(731): std.container.array.Array!(Foo).Array.opSliceAssign(Foo value, ulong i, ulong j) /tmp/dmd2/linux/bin64/../../src/phobos/std/container/array.d(529): Error: template instance std.container.array.RangeT!(Array!(Foo)) error instantiating test.d(3):instantiated from here: Array!(Foo) --
[Issue 20869] `std.algorithm.mutation : move` is overly trusting of `opPostMove`
https://issues.dlang.org/show_bug.cgi?id=20869 Dlang Bot changed: What|Removed |Added Keywords||pull --- Comment #1 from Dlang Bot --- @MoonlightSentinel created dlang/phobos pull request #7502 "Fix Issue 20869 - `move` is overly trusting of `opPostMove`" fixing this issue: - Fix Issue 20869 - `move` is overly trusting of `opPostMove` Remove the manual check whether move is `@safe` and instead let the compiler do the attribute interference by adding appropriate @trusted blocks. Note: I could've extend the current checks `trustedMoveImpl` but that could easily miss other corner cases. https://github.com/dlang/phobos/pull/7502 --
[Issue 19525] Duration is not usable with zero-arg std.algorithm.sum
https://issues.dlang.org/show_bug.cgi?id=19525 Seb changed: What|Removed |Added Status|RESOLVED|REOPENED Resolution|FIXED |--- --- Comment #3 from Seb --- Reopened as the issue hasn't been fixed yet. Duration should work out of the box with sum by e.g. checking whether .zero exists or specializing for the duration type. --
[Issue 19525] Duration is not usable with zero-arg std.algorithm.sum
https://issues.dlang.org/show_bug.cgi?id=19525 Simen Kjaeraas changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --
[Issue 19155] ICE on tuple assignment in mixin template
https://issues.dlang.org/show_bug.cgi?id=19155 Simen Kjaeraas changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #1 from Simen Kjaeraas --- Fixed in 2.082.1 --
[Issue 18785] No way to get list of overloads for a given template
https://issues.dlang.org/show_bug.cgi?id=18785 Simen Kjaeraas changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #1 from Simen Kjaeraas --- Fixed in 2.081.2 --
[Issue 20875] New: [REG2.087.1] Enum template specialization ignored
https://issues.dlang.org/show_bug.cgi?id=20875 Issue ID: 20875 Summary: [REG2.087.1] Enum template specialization ignored Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: simen.kja...@gmail.com enum Foo(alias T : None!U, U...) = true; enum Bar(alias T : None!U, U...) = false; static assert( Foo!(int)); static assert(!Bar!(int)); The above code should of course not compile - None is nowhere defined, so nothing can match, yet it does. --
[Issue 18502] isExpression treated differently in TemplateTypeParameterSpecialization than elsewhere
https://issues.dlang.org/show_bug.cgi?id=18502 Simen Kjaeraas changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |INVALID --
[Issue 20874] New: std.json.assign requires '@safe'
https://issues.dlang.org/show_bug.cgi?id=20874 Issue ID: 20874 Summary: std.json.assign requires '@safe' Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: safe Severity: normal Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: pro.mathias.l...@gmail.com ``` import std.json; struct MyCustomType { public string toString () const @system { return null; } alias toString this; } void main () @system { JSONValue json; MyCustomType ilovedlang; json = ilovedlang; } ``` Results in: ``` /usr/local/opt/dmd/include/dlang/dmd/std/json.d(459): Error: @safe function std.json.JSONValue.assign!(MyCustomType).assign cannot call @system function foo.MyCustomType.toString foo.d(5):foo.MyCustomType.toString is declared here /usr/local/opt/dmd/include/dlang/dmd/std/json.d(593): Error: template instance std.json.JSONValue.assign!(MyCustomType) error instantiating foo.d(13):instantiated from here: opAssign!(MyCustomType) ``` Since `assign` is a template, why is it annotated ? >From the discussion in: https://forum.dlang.org/post/tgpqkdghinutpumko...@forum.dlang.org --
[Issue 17816] Casting of AliasSeq is silently ignored
https://issues.dlang.org/show_bug.cgi?id=17816 Simen Kjaeraas changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #1 from Simen Kjaeraas --- Fixed in 2.086.1 --
[Issue 20873] New: std.parallelism.task mistakenly trusts user-supplied implicit-conversion routines
https://issues.dlang.org/show_bug.cgi?id=20873 Issue ID: 20873 Summary: std.parallelism.task mistakenly trusts user-supplied implicit-conversion routines Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Keywords: safe Severity: enhancement Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: pro.mathias.l...@gmail.com ``` import std.parallelism; void myTask (int a) @safe {} struct Deceptive { public int deception () @system { int* ptr = cast(int*) 42; return *ptr; } alias deception this; } void main () @safe { Deceptive d; auto t = task(, d); taskPool.put(t); t.spinForce(); } ``` Compiles and crash with DIP1000. --
[Issue 20872] New: std.array.assocArray trusts user-provided 'front' for values
https://issues.dlang.org/show_bug.cgi?id=20872 Issue ID: 20872 Summary: std.array.assocArray trusts user-provided 'front' for values Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Keywords: safe Severity: enhancement Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: pro.mathias.l...@gmail.com ``` import std.array; struct KeyRange { @safe: string front () const { return null; } void popFront() {} bool empty() const { return false; } } struct ValueRange { string front () const @system { int* ptr = cast(int*)42; *ptr = 42; return null; } @safe: void popFront() {} bool empty() const { return false; } } void main () @safe { KeyRange keys; ValueRange values; auto ret = assocArray(keys, values); } ``` ``` % dmd -preview=dip1000 -run foo.d Error: program killed by signal 11 ``` --
[Issue 20871] New: std.socket.UnixAddress @trusted functions can corrupt memory if inherited from
https://issues.dlang.org/show_bug.cgi?id=20871 Issue ID: 20871 Summary: std.socket.UnixAddress @trusted functions can corrupt memory if inherited from Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Keywords: safe Severity: enhancement Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: pro.mathias.l...@gmail.com ``` import std.socket; import std.stdio; class Oops : UnixAddress { override void setNameLen (socklen_t) @safe { this._nameLen = 9; } } void main() @safe { auto un = new Oops(); un.setNameLen(0); writeln(un.path()); } ``` ``` dmd -preview=dip1000 -run foo.d !�@h!�@h���"�@h"�@h���#�@h#�@h���$�@h$�@h���%�@h%�@h���&�@h&�@h���'�@h'�@h���(�@h(�@h���)�@h)�@h���*�@h*�@h���+�@h+�@h���,�@h,�@h���-�@h-�@h���.�@h.�@h���/�@h/�@h���@h��� ``` --
[Issue 20870] New: std.outbuffer.printf is trusted
https://issues.dlang.org/show_bug.cgi?id=20870 Issue ID: 20870 Summary: std.outbuffer.printf is trusted Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Keywords: safe Severity: enhancement Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: pro.mathias.l...@gmail.com I don't know how that made it past code review. ``` import std.outbuffer; import std.stdio; void main() @safe { char[8] arr = 'a'; auto buff = new OutBuffer(); buff.printf("%.*s", 45, [0]); writeln(buff.toString()); } ``` This reads random characters off the stack. --
[Issue 20869] New: `std.algorithm.mutation : move` is overly trusting of `opPostMove`
https://issues.dlang.org/show_bug.cgi?id=20869 Issue ID: 20869 Summary: `std.algorithm.mutation : move` is overly trusting of `opPostMove` Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Keywords: safe Severity: enhancement Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: pro.mathias.l...@gmail.com ``` import std.algorithm.mutation; struct S { void opPostMove(const ref S old) @system nothrow pure { int* ptr = cast(int*)42; *ptr = 42; } int a; } void main () @safe nothrow { S s1; s1.a = 41; S s2 = move(s1); assert(s2.a == 42); } ``` --