This project is read-only.
1

Resolved

Static Local : Additional Error for Duplicate Declarations

description

  1. Create a console application and add the following
Imports System
Module Module1
Sub Main()
StaticLocal_DuplicationDeclarations_InSameScopes()
StaticLocal_DuplicationDeclarations_InSameScopes()
End Sub
Sub StaticLocal_DuplicationDeclarations_InSameScopes()
Static x As Integer = 1
Console.WriteLine(x)
Static x As Integer = 2 'Err
Console.WriteLine(x)
End Sub
End Module
  1. Build
EXPECTED RESULT
1 Error
Error 1 Static local variable 'x' is already declared. C:\Users\abowles\Documents\Visual Studio 2012\Projects\ConsoleApplication7\ConsoleApplication7\Module1.vb 12 16 ConsoleApplication7

ACTUAL RESULT
2/3 errors

Error 1 Static local variable 'x' is already declared. C:\Users\abowles\documents\visual studio 2012\Projects\ConsoleApplication8\ConsoleApplication8\Module1.vb 12 16 ConsoleApplication8

Error 2 Local variable 'x' is already declared in the current block. C:\Users\abowles\documents\visual studio 2012\Projects\ConsoleApplication8\ConsoleApplication8\Module1.vb 12 16 ConsoleApplication8


Repro in 21227.10
C:\temp>z:rvbc test.vb
Microsoft (R) Roslyn Visual Basic Compiler version
:
C:\temp\test.vb(10) : error BC30288: Local variable 'x' is already declared in t
he current block.
  Static x As Integer = 2 'Err
         ~
C:\temp\test.vb(10) : error BC31401: Static local variable 'x' is already declar
ed.
  Static x As Integer = 2 'Err
         ~ 

comments

VSadov wrote Apr 23, 2014 at 11:47 PM

Fixed in changeset 7900d09743f8ea042c0f8d52f2e99b14ee81e45a