History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: BOO-467
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Rodrigo B. de Oliveira
Reporter: Joshua W. Biagio
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Boo

Variables can be set to MaxValue + 1

Created: 31/Aug/05 08:16 PM   Updated: 18/Nov/07 10:32 AM
Component/s: None
Affects Version/s: None
Fix Version/s: 0.8.1

Time Tracking:
Not Specified

Environment: Windows XP SP2 / .NET 1.1 SP1
Issue Links:
Related
 


 Description  « Hide
Variables of certain datatypes can be set to MaxValue +1.

Here is a screen dump of a booish session:

---------------------------------
C:\tools\boo\bin>booish
Welcome to booish, an interpreter for the boo programming language.

Running boo 0.6.0.1858.

The following builtin functions are available:
dir(Type): lists the members of a type
help(Type): prints detailed information about a type
load(string): evals an external boo file
globals(): returns the names of all variables known to the interpreter

Enter boo code in the prompt below.
>>> i as short = short.MaxValue
32767
>>> i += 1
32768
>>> i += 1
System.OverflowException: Value was either too large or too small for an Int16.
at System.Convert.ToInt16(Int32 value)
at System.Int32.System.IConvertible.ToInt16(IFormatProvider provider)
at Boo.Lang.Runtime.RuntimeServices.UnboxInt16(Object value)
at Input3Module.Main(String[] argv)
>>>
--------------------------

The "i += 1" call should trigger an overflow error. I believe all of the integral types are affected.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Joshua W. Biagio - 31/Aug/05 08:17 PM
Make that "The first 'i += 1' call should trigger an overflow error.

Joshua W. Biagio - 03/Sep/05 11:09 AM
This appears to be related to the "SetLastValue" and "GetValue" calls in AbstractInterpreter.

---------------------------------------
C:\tools\boo\bin>booish --print-modules
Welcome to booish, an interpreter for the boo programming language.

Running boo 0.6.0.1858.

The following builtin functions are available:
dir(Type): lists the members of a type
help(Type): prints detailed information about a type
load(string): evals an external boo file
globals(): returns the names of all variables known to the interpreter

Enter boo code in the prompt below.
>>> i as short = short.MaxValue
[Boo.Lang.ModuleAttribute]
public final transient class Input1Module(System.Object):

private static def Main(argv as (System.String)) as System.Void:
Input1Module.ParentInterpreter.SetLastValue(Input1Module.ParentInterpreter.SetValue('i', short.MaxValue)
)

private def constructor():
super()

public static ParentInterpreter as Boo.Lang.Interpreter.AbstractInterpreter

32767
>>> i += 45
[Boo.Lang.ModuleAttribute]
public final transient class Input3Module(System.Object):

private static def Main(argv as (System.String)) as System.Void:
Input3Module.ParentInterpreter.SetLastValue(Input3Module.ParentInterpreter.SetValue('i', (cast(System.In
t16, Input3Module.ParentInterpreter.GetValue('i')) + 45)))

private def constructor():
super()

public static ParentInterpreter as Boo.Lang.Interpreter.AbstractInterpreter

32812
>>> i
[Boo.Lang.ModuleAttribute]
public final transient class Input4Module(System.Object):

private static def Main(argv as (System.String)) as System.Void:
Input4Module.ParentInterpreter.SetLastValue(Input4Module.ParentInterpreter.GetValue('i'))

private def constructor():
super()

public static ParentInterpreter as Boo.Lang.Interpreter.AbstractInterpreter

32812
>>>
---------------------------------------

No type or range checking appears to be taking place. Also, the intrinsic value for integral types appears to be Int32... Compare the behavior of int to short (above):

>>> j as int
[Boo.Lang.ModuleAttribute]
public final transient class Input5Module(System.Object):

private static def Main(argv as (System.String)) as System.Void:
pass

private def constructor():
super()

public static ParentInterpreter as Boo.Lang.Interpreter.AbstractInterpreter

>>> j = int.MaxValue
[Boo.Lang.ModuleAttribute]
public final transient class Input6Module(System.Object):

private static def Main(argv as (System.String)) as System.Void:
Input6Module.ParentInterpreter.SetLastValue(Input6Module.ParentInterpreter.SetValue('j', int.MaxValue))

private def constructor():
super()

public static ParentInterpreter as Boo.Lang.Interpreter.AbstractInterpreter

2147483647
>>> j += 1
[Boo.Lang.ModuleAttribute]
public final transient class Input7Module(System.Object):

private static def Main(argv as (System.String)) as System.Void:
Input7Module.ParentInterpreter.SetLastValue(Input7Module.ParentInterpreter.SetValue('j', (cast(System.In
t32, Input7Module.ParentInterpreter.GetValue('j')) + 1)))

private def constructor():
super()

public static ParentInterpreter as Boo.Lang.Interpreter.AbstractInterpreter

System.OverflowException: Arithmetic operation resulted in an overflow.
at Input7Module.Main(String[] argv)
>>>