[REG2.065a] Issue 11822 - -de switch causees ICE with auto return and other stuff#3034
[REG2.065a] Issue 11822 - -de switch causees ICE with auto return and other stuff#30349rnsr wants to merge 3 commits intodlang:masterfrom
-de switch causees ICE with auto return and other stuff#3034Conversation
|
Updated, and auto tester shows green now. @WalterBright , this is contrary change against your error propagation fixes - #2753 and #2850. Can you agree with the reason? |
|
I don't agree with this change, because if we're ever going to make trySemantic and friends work right we have to do proper error propagation. This regression is caused by an overlooked case. |
|
I considered your argument, but again concluded that setting Currently many function-related attributes are stored in If we keep
We can make the overlooked case count zero. This change makes it. Furthermore, not so many places would require the conversion from |
|
The idea with error propagation is that if I do something like: |
|
I'm not against the idea. What I'm saying is, we should continue to keep If error occurs in the body of And, many other places Again, I'm not against for the error propagation itself. I'm saying that your changed had silently broken the assumptions for the internal AST in many semantic processing code. This change is low cost than adjusting over 100 code places. |
|
We should be storing the results of purity/safety/etc inference in the declaration, not the type, and constructing the correct type at the end, right? Then we could safely set the type to |
|
@yebblies But two function types |
|
Oh, we'll need to store that stuff in the function type too. But This is just a long-term idea, I expect it will take quite a bit of work to accomplish. |
|
I don't feel good that idea. It would just add duplication between function declaration and its type. Sync them during semantic processing would be essentially extra cost. |
|
We already have had lots of trouble with function types: parameter names, default parameters, purity/safety inference changing the type etc I guess we'll see what it looks like if/when I get around to it. |
|
The troubles were mostly fixed already:
|
I don't agree with this, but we're getting further off-topic now. |
Right. So, how do you think about this change? Currently once Instead, I think keeping the invariance |
There are two invariants that are in conflict here:
Breaking either one has problems.
I think we need to fix the ICE. If another solution along Walter's suggested line isn't forthcoming, then this will do it. |
|
There are two invariants that are in conflict here:
This change removes the second invariant intentionally. For error propagation, we can use |
|
This fixes it: |
|
@WalterBright I already considered your change. Yes, it would fix the reported ICE. But other ICE possibilities is still there. For example, |
|
@9rnsr if it does occur it will be fixed. I think I got most of them, but wouldn't be surprised if there are a couple more lingering ones. |
|
Yes, we will be able to fix the found bugs. But it is fragile and needs more work. My main point is, stateless code is more robust than stateful code. If we continue current way ( Today, dmd project does not have so many contributors. So we should continue to reduce code complexity to reduce bug possibility. But, your way would need more man-power. It is definitely not good. |
|
@9rnsr we are going to disagree on this one. I believe my approach will work better in the long term, and there's been only regression caused by it (and easily fixed), so I don't see anything fundamentally wrong with it. I agree with your goal of stateless code, and I believe that propagating errors rather than setting global.errors is the right way to go, and the changes I suggested are the most straightforward path to that. |
|
@WalterBright I think you should recognize that function is very special declaration than other declarations which has their own types. (VarDeclaration, StructDeclaration, etc.) As I repeatedly explained, FuncDeclaration and TypeFunction is closely related each other. So, setting type to And, Walter, I also like making things simple. But too simplicity would make other things more complex. I believe that this change will reduce total complexity in front-end layer. I hope you don't add future unnecessary work. |
|
@9rnsr I understand your points, I just do not agree with the conclusion. |
|
When I check issue 11850, I found that the reason of segfault is same as this. (The bug itself was caused by merging #3020, but the segfault is caused by accessing Walter, the change you proposed does not fix 11850. Do you think about that? |
|
Added test case. |
|
With the change I proposed, it does fix 11850. Here is the output: Though it is possible that my fork is a bit behind yours. |
|
Added test case for issue 11857. |
|
@WalterBright I believe this approach is better for the long-term development of dmd. I'll continue to maintain this PR. But, on the other hand, we should fix the ICE regression for 2.065 release. Could you open another PR that implements which based on your approach? If the PR passes auto tester, I'll merge it. |
|
@WalterBright Ping? |
|
@9rnsr I'll do it. |
|
Added test case for issue 11922. |
This reverts commit 24c1dff, excepting test cases.
This reverts commit 11f05b5, excepting test cases.
`TypeFunction` is also used for the extra payload of function attributes. Therefore, even if function signature or its body has errors, we would be better to leave that `fd->type->ty == Tfunction`. Also fix-up test cases for issue 11822, 11850, and 11857
|
This appears to be setting nextOf() to terror instead of the type itself. I still disagree with this - any type that has components that are terror should themselves be replaced with terror. |
I still think that TypeFunction would be an exception. But I seem that the current approach is working so so. So I close this. |
https://d.puremagic.com/issues/show_bug.cgi?id=11822
This is caused by #2850.
TypeFunctionis also used for the extra payload of function attributes. Therefore, even if function signature or its body has errors, we would be better to leave thatfd->type->ty == Tfunction.