mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00

* Fix Issue 12118 - Modify immutable data using throw * Change immutable test to const * Deprecate throwing any qualified type * Allow throw shared as std.concurrency does that * Use static this instead of static const for test * Only allow single shared qualifier or none * Add changelog * Disallow throwing shared objects too * Update changelog/dmd.throw-qualifier.dd Co-authored-by: Razvan Nitu <razvan.nitu1305@gmail.com> --------- Co-authored-by: Razvan Nitu <razvan.nitu1305@gmail.com>
31 lines
675 B
D
31 lines
675 B
D
/*
|
|
TEST_OUTPUT:
|
|
---
|
|
fail_compilation/ice10651.d(13): Error: can only throw class objects derived from `Throwable`, not type `int*`
|
|
fail_compilation/ice10651.d(19): Deprecation: cannot throw object of qualified type `immutable(Exception)`
|
|
fail_compilation/ice10651.d(20): Deprecation: cannot throw object of qualified type `const(Dummy)`
|
|
---
|
|
*/
|
|
|
|
void main()
|
|
{
|
|
alias T = int;
|
|
throw new T(); // ICE
|
|
}
|
|
|
|
void f()
|
|
{
|
|
immutable c = new Exception("");
|
|
if (c) throw c;
|
|
throw new const Dummy([]);
|
|
}
|
|
|
|
class Dummy: Exception
|
|
{
|
|
int[] data;
|
|
@safe pure nothrow this(immutable int[] data) immutable
|
|
{
|
|
super("Dummy");
|
|
this.data = data;
|
|
}
|
|
}
|