[REG2.031] Issue 14965 - Forward reference to inferred return type of function call when using auto return type#5202
Conversation
d85b607 to
2c56587
Compare
|
941b4f2 to
b42243d
Compare
66b06ff to
e8fc4e0
Compare
faa0421 to
cfc9a5c
Compare
4d2f9e0 to
2be998c
Compare
|
Now this PR contains only one bugfix commit. Ready to go. |
…on call when using auto return type If a function symbol is used, its overload resolution should be deferred until: ```d func(...) // CallExp.semantic func.mangleof // DotIdExp.semanticY typeof(func) // TypeTypeof.resolve typeof(&func) // TypeTypeof.resolve auto v = &func; // ExpInitializer.inferType &func; // ExpStatement.semantic return &func; // ReturnStatement ``` When the semantic analysis reaches to them, the function forward reference can beome actual error. Other use of 'func' should be treated as a property-like function call (done in `resolveProperties`) and finally handled in `CallExp`.
|
It's very maintenance intensive to do something by dealing with all occurrences of it in the language. |
|
I'm continuously boiling down things. It's easy to add one new thing quickly, but it's dangerous because we should handle all interactions at once between the new thing and other all existing AST entities. So, we usually should be conservative not to add new things. (OT: I'm proposing to add a new AST entity "ambiguous function type and its derived types" in #2130, but the PR didn't get enough response during 3 years.) |
I think we should try to refactor our code, so it's less hard to add all those interactions. It's also a big maintenance overhead to deal w/ behavior that's scattered throughout the codebase. |
|
So to rephrase my question, can we combine this check w/ something else we already do? |
I agree with you at all, but refactoring is less priority than regression fixes. So I usually don't do unuseful refactoring for bugfixes near the future.
No we cant yet, because function overload handling is yet incomplete (See issue 1983 and others). In other words, we are in progress to find it.
It was impossible. In this PR, I added two abstracts |
|
Auto-merge toggled on |
[REG2.031] Issue 14965 - Forward reference to inferred return type of function call when using auto return type
|
@MartinNowak Thanks! |
[REG2.031] Issue 14965 - Forward reference to inferred return type of function call when using auto return type
https://issues.dlang.org/show_bug.cgi?id=14965
If a function symbol is used, its overload resolution should be deferred until:
When the semantic analysis reaches to them, the function forward reference can beome actual error.
Other use of 'func' should be treated as a property-like function call (done in
resolveProperties) and finally handled inCallExp.Each preparation cleanup/refactoring changes are separated into following pull requests.