Boo

Issues with using nullable types in Boo

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 0.8.2
  • Component/s: Compiler
  • Labels:
    None
  • Number of attachments :
    0

Description

Two issues:

nullable types in Boo don't support implicit casting
nullable types HasValue occasionally flips out.

booish output below:

>>> testVar = Nullable[of long]()
>>> testVar = 3 #int
--------------^
ERROR: Cannot convert 'int' to 'System.Nullable`1[[System.Int64, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'.
>>> testVar = 3L #long
3
>>> testVar = {'1' : DBNull.Value }['1'] #assign null value

>>> testVar.HasValue
System.InvalidCastException: Specified cast is not valid.
at Input25Module.Main(String[] argv)
>>> testVar = 4L
4
>>> testVar.HasValue
true
>>>

Issue Links

Activity

Hide
Cedric Vivier added a comment -

Third issue is that the compiler does not generate an error when declaring "x as Nullable of string" or other non-valuetype.

Show
Cedric Vivier added a comment - Third issue is that the compiler does not generate an error when declaring "x as Nullable of string" or other non-valuetype.
Hide
Cedric Vivier added a comment -

For later reference here's the message used by gmcs :
error CS0453: The type `string' must be a non-nullable value type in order to use it as type parameter `T' in the generic type or method `System.Nullable<T>'.

Show
Cedric Vivier added a comment - For later reference here's the message used by gmcs : error CS0453: The type `string' must be a non-nullable value type in order to use it as type parameter `T' in the generic type or method `System.Nullable<T>'.
Hide
Avishay Lavie added a comment -

(re: third issue) that's because current generics support doesn't validate that generic parameters satisfy their constraints. Generic parameter constraints will be added, I assume, when doing BOO-763, since they're mostly relevant when declaring generic type definitions rather than when constructing types.
I'll add an issue to represent this.

Show
Avishay Lavie added a comment - (re: third issue) that's because current generics support doesn't validate that generic parameters satisfy their constraints. Generic parameter constraints will be added, I assume, when doing BOO-763, since they're mostly relevant when declaring generic type definitions rather than when constructing types. I'll add an issue to represent this.
Hide
Cedric Vivier added a comment -

fixed in rev 2898

Show
Cedric Vivier added a comment - fixed in rev 2898

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: