Boo

Variables can be set to MaxValue + 1

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 0.8.1
  • Component/s: None
  • Labels:
    None
  • Environment:
    Windows XP SP2 / .NET 1.1 SP1
  • Number of attachments :
    0

Description

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.

Issue Links

Activity

Hide
Joshua W. Biagio added a comment -

Make that "The first 'i += 1' call should trigger an overflow error.

Show
Joshua W. Biagio added a comment - Make that "The first 'i += 1' call should trigger an overflow error.
Hide
Joshua W. Biagio added a comment -

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)
>>>

Show
Joshua W. Biagio added a comment - 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) >>>

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: