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 Issue 20692 - Nested alias declarations and getMember trait can c… #10952

Merged
merged 1 commit into from
Mar 31, 2020

Conversation

BorisCarvajal
Copy link
Member

…rash dmd

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @BorisCarvajal! 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: and Returns:)

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
20692 normal Nested alias declarations and getMember trait can crash dmd

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 "stable + dmd#10952"

@RazvanN7
Copy link
Contributor

Can you please offer an explanation describing the problem and explaining the fix? Honestly, I would expect that the provided test case fails with a "forward reference" error, since dmd isn't able to partially analyze structs

@BorisCarvajal
Copy link
Member Author

BorisCarvajal commented Mar 26, 2020

Indeed that could be a possible outcome of compilation if dmd were not able to resolve the symbol, and maybe dmd should give up on the first analyzing pass on the function.
But in this case dmd can really resolve the alias in the second recursive try on the function gun.

Let me remember the changes:

  • In the first inspection of gun(), the symbol can't be resolved in the first part of aliasSemantic() code and then lies the first problem, it calls to toDsymbol but it's not defined for TypeTraits so it returns null for everything, given the fact that TypeTraits can contain types or symbols I naturally put one definition there.
  • Now comes a TypeTraits typeSemantic call with the second triggered bug, there was a scope flag manipulation code in aliasSemantic that removed SCOPE.alias_ from the input scope on exit not taking care if it already had that flag set, somehow this function is called with the same previous scope but without the alias_ flag and if the trait resolves to a symbol not within an alias scope it will fail with an error.

Edit: I've forgotten if the point one (the problematic toDsymbol call) strictly happens in AliasDeclaration.toAlias or aliasSemantic.

@RazvanN7 RazvanN7 merged commit a22ea07 into dlang:stable Mar 31, 2020
kinke added a commit to kinke/dmd that referenced this pull request Apr 12, 2020
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.

3 participants