[Mono-list] const weirdness

Daniel Carrera dcarrera@math.toronto.edu
Sun, 7 Apr 2002 04:17:57 -0400 (EDT)


Well, you declared myInt to be a constant and then you tried to change the
value.  Thus I'd expect that it should fail.

However, I would expect mcs to fail more elegantly that it did.  Maybe
something like:

"Error: line 8, cannot assign value to constant"


Daniel.


On Sun, 7 Apr 2002, Jonathan Stowe wrote:

> This fails to compile as it should:
>
> class Values
> {
>     static void Main()
>     {
>         const int myInt  = 7;
>         myInt = 5;
>     }
>
> }
>
> However unless I am missing something this is not how it should fail:
>
>
> (process:12689): ** WARNING **: unhandled exception
> System.FormatException: "The specified format is invalid"
> in System.IntegerFormatter:NumberToString ()
> in System.Int32:ToString ()
> in System.String:Format ()
> in System.String:Format ()
> in Mono.CSharp.Report:Error ()
> in Mono.CSharp.Assign:DoResolve ()
> in Mono.CSharp.Expression:Resolve ()
> in Mono.CSharp.StatementExpression:Emit ()
> in Mono.CSharp.Block:Emit ()
> in Mono.CSharp.EmitContext:EmitTopBlock ()
> in Mono.CSharp.Method:Emit ()
> in Mono.CSharp.TypeContainer:Emit ()
> in Mono.CSharp.RootContext:EmitCode ()
> in Mono.CSharp.Driver:MainDriver ()
> in Mono.CSharp.Driver:Main ()
>
>
> /J\
>