Structs defined inside functions behave as global definitions #22437
Labels
Bug
This tag is applied to issues which reports bugs.
Status: Confirmed
This bug has been confirmed to be valid by a contributor.
Unit: Compiler
Bugs/feature requests, that are related to the V compiler in general.
Describe the bug
Structs defined inside functions act as if they were defined in global scope. This allows structs to be accessed outside their scope of definition.
Reproduction Steps
Expected Behavior
Structs defined inside functions should have local scope and should not be accessible outside their defining function. Attempting to access such structs outside their scope should result in a compilation error.
Current Behavior
Possible Solution
It may be possible to remove the type symbol from the table after the parser ends the current scope.
Additional Information/Context
Struct definitions inside functions were added in a2d385a.
V version
V 0.4.8 d3c3c39
Environment details (OS name and version, etc.)
Huly®: V_0.6-20898
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: