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
Alternative fix to issue 17548 - [REG2.072.0] Forward reference error with scope function parameters #6937
Conversation
Thanks for your pull request, @Syniurge! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up:
Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. Bugzilla references
|
I have a question about this code in else if (symtab && !scx)
{
semanticRun = PASSsemanticdone;
return;
} What's the rationale? Is it assuming that this may only happen if there was a previous if (!determineFields())
{
assert(type.ty == Terror);
sc2.pop();
return;
} which is why it sets If yes the assumption's wrong, and a proper fix would probably be to get rid of that assignment? |
…ction parameters Prior to this commit, in StructDeclaration.semantic the only two ways the condition (symtab && !scx && semanticRun < PASSsemanticdone) may be true are: - if determineFields() fails - if a first semantic() call on the same struct is ongoing But in the second case, setting semanticRun to PASSsemanticdone is wrong, because if the semantic() call defers itself, the deferred semantic() call will return immediately, resulting in a "has forward references" error during semantic2().
So this works too: else if (symtab && !scx)
- {
- semanticRun = PASSsemanticdone;
return;
- }
(...)
if (!determineFields())
{
assert(type.ty == Terror);
sc2.pop();
+ semanticRun = PASSsemanticdone;
return;
} and I think this is the proper fix. Why isn't the auto-tester running though? |
@braddr Here's another instance of the autotester apparently ignoring a PR. |
In this case, it's easy.. new user, not approved yet for builds to be processed. Just look here: |
Aah, forgot about that, thanks! Edit: Approved @Syniurge. |
@WalterBright this looks okay at a glance. |
Ping? |
@@ -323,10 +323,8 @@ extern (C++) class StructDeclaration : AggregateDeclaration | |||
userAttribDecl = sc.userAttribDecl; | |||
} | |||
else if (symtab && !scx) | |||
{ | |||
semanticRun = PASSsemanticdone; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, so the problem was that we set this to done here, even though we might be in a recursive call to StructDeclaration.semantic, with the outer semantic still ongoing on it's members, hence providing wrong semanticRun state info for any further members.
Alternative fix to issue 17548 - [REG2.072.0] Forward reference error with scope function parameters merged-on-behalf-of: Martin Nowak <code@dawg.eu> cherry-picked-by: Martin Krejcirik <mk@krej.cz>
Previous PR: #6934
This one line fix ensures that if a
StructDeclaration.semantic()
call has to defer itself,semanticRun
is set toPASSsemantic
, because it may already have been set toPASSsemanticdone
if a secondStructDeclaration.semantic()
call on the same struct happened while semantic'ing its members (see how in the Bugzilla issue) and then the deferred call would immediately return.