Page MenuHomeFeedback Tracker

Variable declarations are not scoped to the inner code block if the code block is not the body of a control flow construct.
Closed, ResolvedPublic

Description

For example:
"
if(1)
{
int i = 0;
}
if(1)
{
int i = 0;
}
"
is a valid code sequence, but:
"
{
int j = 0;
}
{
int j = 0;
}
" Is invalid due to 'multiple declarations' of j.
This is annoying.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 7
Category
General
Steps To Reproduce

Already described in description.

Event Timeline

Geez changed the task status from New to Assigned.Nov 21 2024, 11:51 AM
Geez closed this task as Resolved.Nov 22 2024, 12:04 AM
Geez claimed this task.
Geez added a subscriber: Geez.

Hello colourScreen.
According to the devs, this is intended. Only flow expressions create scopes.
Regards,
Geez