Page MenuHomeFeedback Tracker

Enscript variable initialization bug
Reviewed, NormalPublic

Description

Imagine the following code:

int a = a + 1;

Currently this compiles and runs, the output is 1. This shouldn't be allowed and should throw a compile error along the lines of "usage of undefined variable 'a'". The value in the initializer expression seems to be the default value of the type, so for the case above, it's 0, for strings it would be "", null for reference types, etc. My type analyzer caught only a single occurance of this, Scripts/Game/UI/Components/MainMenu/SCR_CommunitySubMenu.c line 112,

string content = content + m_Feedback.GetValue();

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce

Run

int a = a + 1;
Print(a);

Event Timeline

Geez changed the task status from New to Awaiting internal Testing.Aug 30 2022, 12:51 PM
Geez changed the task status from Awaiting internal Testing to Reviewed.Nov 10 2022, 2:51 PM
Geez added a subscriber: Geez.

Hello sharp1337.
This works as designed according to the devs.
Regards,
Geez