Skip to content

Commit 2117cc1

Browse files
committed
Make throw of qualified type an error
1 parent b572cd7 commit 2117cc1

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

changelog/dmd.deprecations.dd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
Many deprections have been turned in errors
22

33
Using `return` statements in scope guards is now an error (in addition to contracts and `try...finally`)
4+
5+
Throwing `Throwable`s of qualified types

compiler/src/dmd/statementsem.d

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3942,10 +3942,8 @@ public bool throwSemantic(Loc loc, ref Expression exp, Scope* sc)
39423942
return false;
39433943
if (!exp.type.isNaked)
39443944
{
3945-
// @@@DEPRECATED_2.112@@@
3946-
// Deprecated in 2.102, change into an error & return false in 2.112
3947-
eSink.deprecation(exp.loc, "cannot throw object of qualified type `%s`", exp.type.toErrMsg());
3948-
//return false;
3945+
eSink.error(exp.loc, "cannot throw object of qualified type `%s`", exp.type.toErrMsg());
3946+
return false;
39493947
}
39503948
checkThrowEscape(*sc, exp, false);
39513949

compiler/test/fail_compilation/ice10651.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
TEST_OUTPUT:
33
---
44
fail_compilation/ice10651.d(13): Error: can only throw class objects derived from `Throwable`, not type `int*`
5-
fail_compilation/ice10651.d(19): Deprecation: cannot throw object of qualified type `immutable(Exception)`
6-
fail_compilation/ice10651.d(20): Deprecation: cannot throw object of qualified type `const(Dummy)`
5+
fail_compilation/ice10651.d(19): Error: cannot throw object of qualified type `immutable(Exception)`
6+
fail_compilation/ice10651.d(20): Error: cannot throw object of qualified type `const(Dummy)`
77
---
88
*/
99

0 commit comments

Comments
 (0)