Bug 22053 – `catch {` not rejected while in a template

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-06-20T21:27:18Z
Last change time
2021-06-22T02:03:02Z
Keywords
accepts-invalid, pull
Assigned to
No Owner
Creator
Vladimir Panteleev

Comments

Comment #0 by dlang-bugzilla — 2021-06-20T21:27:18Z
/////// test.d /////// void foo()() { try {} catch assert(false); } alias goo = foo!(); ////////////////////// This catch syntax (without specifying an exception) has been deprecated and is currently rejected when the code is not in a function template. However, the compiler does not reject it when it's inside a template, even when the template is instantiated.
Comment #1 by dlang-bot — 2021-06-21T09:15:04Z
@Geod24 created dlang/dmd pull request #12721 "Fix 22053: Deprecate typeless catch at the parser level" fixing this issue: - Fix 22053: Deprecate typeless catch at the parser level Type-less catch was previously deprecated only at the semantic level. This is usually good, because it avoids spurious deprecations being triggered in versioned-out code or generally unused (uninstantiated) code, or in code that is 'deprecated'. However, the syntax has been deprecated for years now, and should ultimately be removed from the parser, but while validating the grammar, it was found that the deprecation message didn't actually trigger in templated code, even instantiated. While we could fix it by triggering a deprecation only when the code is instantiated, this would still prevent us from removing support for parsing it. Instead, add a deprecation in the parser, so that code that wasn't caught before will be. The existing error is left in place, ensuring we don't regress. https://github.com/dlang/dmd/pull/12721
Comment #2 by dlang-bot — 2021-06-22T02:03:02Z
dlang/dmd pull request #12721 "Fix 22053: Deprecate typeless catch at the parser level" was merged into master: - 85a12332f275a19b8e291489f3beb6e907310295 by Geod24: Fix 22053: Deprecate typeless catch at the parser level Type-less catch was previously deprecated only at the semantic level. This is usually good, because it avoids spurious deprecations being triggered in versioned-out code or generally unused (uninstantiated) code, or in code that is 'deprecated'. However, the syntax has been deprecated for years now, and should ultimately be removed from the parser, but while validating the grammar, it was found that the deprecation message didn't actually trigger in templated code, even instantiated. While we could fix it by triggering a deprecation only when the code is instantiated, this would still prevent us from removing support for parsing it. Instead, add a deprecation in the parser, so that code that wasn't caught before will be. The existing error is left in place, ensuring we don't regress. https://github.com/dlang/dmd/pull/12721