-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
cgen: fix codegen for generated tmp var to fit number of indirections from fn argument #22752
base: master
Are you sure you want to change the base?
Conversation
I think code like that should not be allowed, at most it should be allowed if the argument is a simple reference type ( In case the argument is of reference to reference type ( |
It's a hard philosophical question. Many people in the community think there should be no autoref/deref, I think that a modern language should handle it. |
In 2025+ I don't want to remember, do I have to pass Config or &Config etc. |
But indeed maybe it should only be done for &Foo, but not for &&&&&Foo, which is too low level and rare. |
what about just |
It's just logical. One wouldn't expect the reference to be automatically taken from reference to reference and so on, it's illogical.. just a simple reference is fine, but with more than 1?
For that case we could simply use the autocomplete of any editor or check the documentation of the function that is receiving the value of
Exactly! It makes no logic to apply the autoref/deref with more than one reference. Doing it with just one is fine and perfect.
Although it is true that it is a common case, it is best to leave it explicitly, to avoid entanglements and confusion. |
All the intermediate temporary variables here, are generated on the stack, in cgen, thus the checker knows nothing about them. If the produced higher level pointer, is then stored in a struct or returned back, or otherwise escape the function, you will get a very hard to debug situation, that can not be checked at compile time, and is hard to catch at runtime too (if you are lucky, you will get an invalid memory access soon ... if not, you will get silent reading/writing of garbage data, that could be very far from where it becomes visible) ... Imho strict counting of pointer levels, without any guessing, and auto
|
Fix #22749
Huly®: V_0.6-21198