[Issue 23941] New: [DIP1000] Overloading by scope should be allowed
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun May 28 08:41:09 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23941
Issue ID: 23941
Summary: [DIP1000] Overloading by scope should be allowed
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: safe
Severity: enhancement
Priority: P3
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dlang-bugzilla at thecybershadow.net
I think this should work (with -preview=dip1000):
///////////////////////// test2.d ////////////////////////
@safe:
import std.stdio;
char[] global;
void a(char[] arr) { writeln("non-scope"); global = arr; }
void a(scope char[] arr) { writeln("scope"); }
void b(scope char[] arr)
{
a(arr);
}
void c()
{
char[16] arr;
b(arr[]);
}
//////////////////////////////////////////////////////////
Currently, it complains:
test2.d(12): Error: `test2.a` called with argument types `(char[])` matches
both:
test2.d(7): `test2.a(char[] arr)`
and:
test2.d(8): `test2.a(scope char[] arr)`
However, when removing one of the overloads, the program only compiles with the
non-scope one, so the compiler should be able to reduce the overload set to a
single viable overload.
--
More information about the Digitalmars-d-bugs
mailing list