Bug 20912 – Compiler incorrectly lists non-matching overloads as matching in diagnostic

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-06-09T03:48:05Z
Last change time
2024-12-13T19:09:08Z
Assigned to
No Owner
Creator
Andrej Mitrovic
Moved to GitHub: dmd#19718 →

Comments

Comment #0 by andrej.mitrovich — 2020-06-09T03:48:05Z
----- struct Struct { int get() { return 1; } } public T execute (T)(T function(ref Struct) @safe dg) { Struct rng; return dg(rng); } public T execute (T)(T delegate(ref Struct) @safe dg) { Struct rng; return dg(rng); } void main (string[] args) { execute((ref Struct rng) { return rng.get(); }); } ----- $ dmd test.d test.d(20): Error: test.execute called with argument types (int function(ref Struct rng) @system) matches both: test.d(6): test.execute!int.execute(int function(ref Struct) @safe dg) and: test.d(12): test.execute!int.execute(int delegate(ref Struct) @safe dg) This is wrong. The call doesn't match either of those calls, that is the actual error here. Because it tries to call `rng.get()` which is an unsafe function.
Comment #1 by razvan.nitu1305 — 2023-04-17T15:24:23Z
*** Issue 21683 has been marked as a duplicate of this issue. ***
Comment #2 by robert.schadek — 2024-12-13T19:09:08Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19718 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB