Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 22053: Deprecate typeless catch at the parser level #12721

Merged
merged 1 commit into from
Jun 22, 2021

Conversation

Geod24
Copy link
Member

@Geod24 Geod24 commented Jun 21, 2021

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.

@Geod24 Geod24 requested a review from CyberShadow June 21, 2021 09:14
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @Geod24!

Bugzilla references

Auto-close Bugzilla Severity Description
22053 normal `catch {` not rejected while in a template

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#12721"

@@ -6413,8 +6413,10 @@ LagainStc:
const catchloc = token.loc;

nextToken();
if (token.value == TOK.leftCurly || token.value != TOK.leftParenthesis)
if (token.value != TOK.leftParenthesis)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed because if token.value == TOK.leftCurly, then token.value != TOK.leftParenthesis.

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.
@WalterBright
Copy link
Member

P.S. Thanks for the nice explanation.

@dlang-bot dlang-bot merged commit 46cc824 into dlang:master Jun 22, 2021
@Geod24 Geod24 deleted the fix-22053 branch June 22, 2021 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants