dmd
dmd copied to clipboard
Fix Issue 13732 - non-member templates can use "template this"
Error if a TemplateThisParameter is declared when there's no parent aggregate type ~~or template (it could be for a mixin)~~.
Thanks for your pull request and interest in making D better, @ntrel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:
- My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
- My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
- I have provided a detailed rationale explaining my changes
- New or modified functions have Ddoc comments (with
Params:
andReturns:
)
Please see CONTRIBUTING.md for more information.
If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.
Bugzilla references
Auto-close | Bugzilla | Severity | Description |
---|---|---|---|
✓ | 13732 | normal | Regular templates can use "template this", and they allow any type to be passed |
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#14434"
The grammar considers this
a primary expression, so it should be a semantic error instead of parser error
The grammar says this is just a token:
TemplateThisParameter: this TemplateTypeParameter
I'm not sure how to make it a semantic check. In templateparametersem.d there is Scope sc
available, is that enough to determine if there's a parent type or template?
The grammar says this is just a token:
You're right. What I really meant to say was: the grammar allows it outside an aggregate, so the parser should not reject it or the grammar needs to be updated as well.
I'm not sure how to make it a semantic check. In templateparametersem.d there is
Scope sc
available, is that enough to determine if there's a parent type or template?
I'll take a look later.
In templateparametersem.d there is
Scope sc
available, is that enough to determine if there's a parent type or template?
I don't know what templateparametersem.d refers to, but I think you can do the check in dsymbolsem.d
in either DsymbolSemanticVisitor.visit(TemplateDeclaration)
or templateInstanceSemantic()
.
@ntrel Just group the error messages in the test case and we can get this in.