Ticket #258 (closed defect: fixed)
Cobra int (primitive) not recognised as implementing underlying type interfaces
Reported by: | hopscc | Owned by: | Chuck |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | Cobra Compiler | Version: | 0.8.0 |
Keywords: | Cc: |
Description
Discovered this on (cobra) int but suspect it applies to all the cobra
primitive system alias types (int, float, char,...)
The Cobra compiler doesn't recognise that a cobra int implements IComparable interface ( or any of the Interfaces the underlying .Net type supports)
Following contrived example
class IntNotIComp def main i as int = 47 i1 as int = 46 #i as Int32 = 47 #i1 as Int32 = 46 b = .chkIGt(i, i1) assert b print b def chkIGt(i as IComparable, i1 as IComparable) as bool if i.compareTo(i1) >0 return true return false
emits
intIcomparable.cobra(7): error: Argument 1 of method "chkIGt" expects type IComparable, but the call is supplying type int. intIcomparable.cobra(7): error: Argument 2 of method "chkIGt" expects type IComparable, but the call is supplying type int. Compilation failed - 2 errors, 0 warnings
Whereas if the commented lines are enabled (and the explicit typing to 'int' commented) the cobra compiler allows compilation (modulo a warning to 'Use the builtin type "int32" instead of the struct "Int32"').
Looks like the system alias types need some enhancement either explicitly describing the interfaces they support or copying the interfaces the underlying types support.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.