Bug 2087 - Compiler exits with "internal compiler error" if variable is declared after usage
Summary: Compiler exits with "internal compiler error" if variable is declared after u...
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: VisualBasic ()
Version: unspecified
Hardware: PC Mac OS
: Low normal
Target Milestone: ---
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
: 3769 ()
Depends on:
Blocks:
 
Reported: 2011-11-18 06:46 UTC by Jannik
Modified: 2012-07-05 05:11 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jannik 2011-11-18 06:46:35 UTC
Hi,

the compiler exits with an error, when compiling the following code:

---

Imports System

Public Class Base

        Public Sub New(ByVal param As Integer)
        End Sub

End Class

Public Class D
        Inherits Base

        Public Sub New(ByVal newParam As Integer)
                MyBase.New(p)
                Dim p As Integer = newParam
        End Sub
End Class


---
(Please note the usage of p before the actual declaration)

Output:

Visual Basic.Net Compiler version 0.0.0.5943
Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved.

/Users/apfelbox/Desktop/test.vb (14,30) : Error VBNC99999: Internal compiler error close to this location
/Users/apfelbox/Desktop/test.vb (14,30) : Error VBNC99999: Internal compiler error close to this location
/Users/apfelbox/Desktop/test.vb (14,29) : Error VBNC99999: Internal compiler error close to this location
Error : VBNC99999: Unexpected error: There has been an internal error in the compiler caused by the line: (14,30)
  at vbnc.VariableToValueExpression.GenerateCodeInternal (vbnc.EmitInfo Info) [0x00000] in <filename unknown>:0 
  at vbnc.Expression.GenerateCode (vbnc.EmitInfo Info) [0x00000] in <filename unknown>:0 
Compilation took 00:00:00.9480460
Comment 1 Atin 2011-12-29 02:05:54 UTC
We have create C3 Empty project and paste the mentioned code in the class file and then build the project, below mentioned error is displayed:


/Users/nichal/Projects/seventh/seventh/abc.cs(21,21): Error CS0128: A local variable named `p' is already defined in this scope (CS0128) (seventh)

seventh is the project name.

Please suggest regarding the same issue.

Environments:
MAC 10.7
Mono Develop 2.8.5 Stable.
Mono Touch 5.0.4 Stable
Mono Framework 2.0.7 Beta
Comment 2 Rolf Bjarne Kvinge [MSFT] 2012-01-02 08:16:13 UTC
Atin: are you sure you commented on the right bug? This bug has nothing to do with MonoTouch.
Comment 3 Atin 2012-01-02 08:30:25 UTC
I created a Mono Touch single view project and added a class . I put provided code into the class file and then build the project, below mentioned error is displayed:

/Users/nichal/Projects/seventh/seventh/abc.cs(21,21): Error CS0128: A local
variable named `p' is already defined in this scope (CS0128) (seventh)

Please suggest in which environment I have to test this issue.
Comment 4 Rolf Bjarne Kvinge [MSFT] 2012-01-02 08:44:10 UTC
Atin: I think you tested a different bug and wrote the comment on this bug, because it is impossible to get that error with the code the reporter provided (because it is Visual Basic code, not C# code).

In any case this is not a MonoTouch bug (nor related to any of our commercial products), so it's not a bug you should test.
Comment 5 Atin 2012-01-02 08:57:23 UTC
I have change the provided code format to c# and then build this code below is the code which I used:

using System

public Class Base
{

        public SubNew()
         {
        Console.WrilteLine("Hello");
         }

}

public Class D:Base
        {

        public Sub New()
                {
                MyBase.New(p);
                Dim p As Integer = newParam;
       }
}
Comment 6 Rolf Bjarne Kvinge [MSFT] 2012-07-04 20:28:50 UTC
Fixed (master: 5d1b471395be3c48d715a77d5b2ec35b2d4fef56).
Comment 7 Rolf Bjarne Kvinge [MSFT] 2012-07-05 05:11:16 UTC
*** Bug 3769 has been marked as a duplicate of this bug. ***