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

Moved resolveAliasThis from aliasthis.d to expressionsem.d #11743

Merged
merged 1 commit into from
Sep 22, 2020

Conversation

AsterMiha
Copy link
Contributor

To separate semantic elements from aliasthis.d

@dlang-bot
Copy link
Contributor

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

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

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

@MoonlightSentinel
Copy link
Contributor

Could you elaborate how this helps dmd as a library?
(dsymbolsem.d is already quite large and this code is explicitly dealing with alias this)

@RazvanN7
Copy link
Contributor

@MoonlightSentinel The general idea is that we want to be able to have a clear separation between files required at parse time and files required for semantic analysis. Currently, to be able to do this we have the massive duplication of code in ASTBase. This is an effort to get rid of that duplication. At the end we are going to have files that contain AST nodes with their fields and simple methods that do not require semantic analysis and other files that contain functions that operate semantic analysis on the AST.

Although, it might be better to put the function in expressionsem.d since that is where it is mostly used.

Copy link
Contributor

@RazvanN7 RazvanN7 left a comment

Choose a reason for hiding this comment

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

See comments below.

}
return e;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

The function below checkDeprecatedAliasThis should also be moved wherever resolveAliasThis goes and also it should be made private. There are 2 reasons for this: firstly, because it is a helper function and only resolveAliasThis calls it, secondly, because it also imports dsymbolsem and therefore has a dependency to a module that does semantic analysis.

@@ -636,6 +636,69 @@ package bool allowsContractWithoutBody(FuncDeclaration funcdecl)
return true;
}

Expression resolveAliasThis(Scope* sc, Expression e, bool gag = false)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that it is a better fit to move resolveAliasThis to expressionsem.d. There are no calls to this function in dsymbolsem.d and the operations are performed on an expressions, so technically it could be seen as been part of semantic on an expression.

Also, putting it in expressionsem will also make some of the imports to dsymbolsem that you added unnecessary.

@Geod24
Copy link
Member

Geod24 commented Sep 17, 2020

The general idea is that we want to be able to have a clear separation between files required at parse time and files required for semantic analysis.

Why ? Is it because you want to provide the ability to have DMD as a library work as a parser only ? If so, don't bother with that. Or rather, not now. We already have libdparse, which was built as a library, and almost everyone uses it for parsing D code, because it's much easier to deal with. The value in DMD as a library is not in the parser, but in the post-semantic AST.

@RazvanN7
Copy link
Contributor

RazvanN7 commented Sep 17, 2020

Why ? Is it because you want to provide the ability to have DMD as a library work as a parser only ?

That is possible already, but you need to use ASTBase. If we want to get rid of that code duplication we must have this separation.

@RazvanN7
Copy link
Contributor

Just to make things clear, we have 2 goals: (1) pull out semantic functions from AST nodes AND (2) get rid of ASTBase. Both goals are targeted to make the code base cleaner, however, (2) requires some changes that are orthogonal to (1). This PR is targeted towards achieving (2).

@AsterMiha AsterMiha changed the title Moved resolveAliasThis from aliasthis.d to dsymbolsem.d Moved resolveAliasThis from aliasthis.d to expressionsem.d Sep 17, 2020
@RazvanN7 RazvanN7 added the Merge:72h no objection -> merge The PR will be merged if there are no objections raised. label Sep 18, 2020
@Geod24
Copy link
Member

Geod24 commented Sep 18, 2020

(1) pull out semantic functions from AST nodes AND (2) get rid of ASTBase.

Alright, that is slightly different. And IMO ASTBase was the wrong approach to begin with, for the reason I mentioned above.
Anyway, if you want to get this merged, at least squash (and get rid of the merge commit).

@RazvanN7 RazvanN7 merged commit cee9a38 into dlang:master Sep 22, 2020
@ibuclaw
Copy link
Member

ibuclaw commented Oct 5, 2020

This caused a regression https://issues.dlang.org/show_bug.cgi?id=21294

@ibuclaw
Copy link
Member

ibuclaw commented Oct 6, 2020

This caused another regression https://issues.dlang.org/show_bug.cgi?id=21295

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merge:72h no objection -> merge The PR will be merged if there are no objections raised.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants