Skip to content

[refactor] remove DiagnosticReporter from core compiler#10711

Merged
RazvanN7 merged 1 commit intodlang:masterfrom
rainers:move_diagreport
Feb 7, 2020
Merged

[refactor] remove DiagnosticReporter from core compiler#10711
RazvanN7 merged 1 commit intodlang:masterfrom
rainers:move_diagreport

Conversation

@rainers
Copy link
Member

@rainers rainers commented Jan 6, 2020

and move it into the frontend library files instead.

Now that #10072 is in, we can use it to implement the DiagnosticReporter outside of the core compiler.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @rainers!

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 fetch digger
dub run digger -- build "master + dmd#10711"


auto o = p.parseTypeOrAssignExp(TOK.endOfFile);
if (p.errors)
if (errors != global.errors)
Copy link
Member Author

Choose a reason for hiding this comment

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

The p.errors checks have been slightly wrong because they ignore warnings emitted as errors. There are only two warnings shown by parsing and lexing, though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to make that change together with refactorings?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, it's more or less a revert of the respective change in the introducing commit. I'm not sure it makes much sense to fix it in the DiagnosticReporter just to rip it out afterwards.

@rainers rainers force-pushed the move_diagreport branch 5 times, most recently from 8516b06 to 81a76bd Compare January 7, 2020 07:39
Copy link
Contributor

@jacob-carlborg jacob-carlborg left a comment

Choose a reason for hiding this comment

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

I think this is a step backwards. Now the lexer and parser will depend on more global state.


auto o = p.parseTypeOrAssignExp(TOK.endOfFile);
if (p.errors)
if (errors != global.errors)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to make that change together with refactorings?

@rainers rainers force-pushed the move_diagreport branch 2 times, most recently from 60f9b7b to 254375b Compare January 7, 2020 08:05
@rainers
Copy link
Member Author

rainers commented Jan 7, 2020

I agree that global state should be minimized, but this allows the DiagnosticReporter to be used for semantic analysis aswell. I don't see this realistically happening otherwise by passing around some extra object everywhere.

@rainers
Copy link
Member Author

rainers commented Jan 7, 2020

@jacob-carlborg I understood your comment here (#10072 (comment)) as agreeing on a change like this.

@jacob-carlborg
Copy link
Contributor

I was thinking a delegate could be passed to the lexer and parser instead of a class.

@WalterBright WalterBright added the Merge:72h no objection -> merge The PR will be merged if there are no objections raised. label Feb 2, 2020
@RazvanN7 RazvanN7 merged commit 4b2a75a into dlang:master Feb 7, 2020
@ibuclaw
Copy link
Member

ibuclaw commented Apr 12, 2020

This caused a regression (seen on forums), creating a reduced test.

@ibuclaw
Copy link
Member

ibuclaw commented Apr 12, 2020

Reduced test and bug report created: https://issues.dlang.org/show_bug.cgi?id=20730

o = p.parseTypeOrAssignExp(TOK.endOfFile);
if (p.errors ||
p.token.value != TOK.endOfFile)
if (errors != global.errors || p.token.value != TOK.endOfFile)
Copy link
Member

Choose a reason for hiding this comment

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

I think the problem is here, this check is done whilst gagging is turned on, unlike in other places where p.errors was replaced with errors != global.errors.

@ibuclaw
Copy link
Member

ibuclaw commented Apr 12, 2020

Proposed fix in #11023.

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