-
Notifications
You must be signed in to change notification settings - Fork 79
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
Types cannot switch from complete to incomplete #93
Comments
respect the rule of scope? |
Hi @Piping, thanks for your message! This bug is a bit tricky: the variable ShivyC currently handles this code like so:
One way to fix this is to add information on type completion in the top level of the symbol table rather than the level of the symbol table that contains the variable. Then, to determine the final type of an incomplete variable, the symbol table would need to be traversed from the layer containing the variable all the way to the top. Alternatively, it may be simpler to create a second stack to keep track of scoped type changes so they are easily "unapplied" when an inner scope is exited. Let me know if this is unclear. If you'd like to contribute to fixing the bug, I'd be happy to give some more code pointers also. |
Thanks for your input. Both And they have a different type, thus C compiler treat them differently. The =========================== Maybe I am wrong after I checked the compiler explorer output. One possible reason is that |
Hmm. I was under the impression What do you mean by " |
Be precise, I mean And yes, those two A should be the same object in the binary. But |
Gotcha, I think we agree. When exiting the function scope, ShivyC should be resetting the type to what it originally was, and this bug is that ShivyC fails to do so. |
Not really. C is a nested scope language, and a function is just one level of scoping. Any P.S. Cute project, thanks for it ;-). |
Thanks @pfalcon! That is how ShivyC implements variable scoping today. Unfortunately, the type of each object (in our case, |
Ah, good to know! (Sorry, it's in my queue to look into depth of ShivyC, but so far I just managed to start watching project on github to see its progress). I'd personally still treat a case like:
As an example of complete shadowing, i.e. global scope |
In some cases, a type should switch from complete to incomplete, like in the code sample below.
ShivyC does not permit this: once a type is completed in ShivyC, it remains completed for the rest of the translation unit. It is unclear to me whether ShivyC's behavior is incorrect or not per the letter of the spec.
The text was updated successfully, but these errors were encountered: