dmd icon indicating copy to clipboard operation
dmd copied to clipboard

fix Issue 15298 - Can't call nested template function unless it's anonymous

Open ibuclaw opened this issue 4 years ago • 3 comments

Treat nested template functions the same as template function literals when passing them by alias.

ibuclaw avatar Aug 23 '21 14:08 ibuclaw

Thanks for your pull request, @ibuclaw!

Bugzilla references

Auto-close Bugzilla Severity Description
15298 normal Can't call nested template function unless it's anonymous
21287 normal Delegate in global template can't call non-anonymous nested function passed as alias

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#13006"

dlang-bot avatar Aug 23 '21 14:08 dlang-bot

I'm really not convinced that this should be considered valid code, because now templates with two alias parameters no longer compile due to lack of dual context support - see failing testsuite of real world projects.

ibuclaw avatar Aug 23 '21 17:08 ibuclaw

The spec says:

If a template has a template alias parameter, and is instantiated with a local symbol, the instantiated function will implicitly become nested in order to access runtime data of the given local symbol.

So, if these examples should not be considered valid, then the spec needs to be updated to explain which local symbols cause implicit nesting and which don't.

pbackus avatar Aug 23 '21 17:08 pbackus