catb0t / tart

Automatically exported from code.google.com/p/tart
0 stars 0 forks source link

Another surprising type error message #9

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I had to do some index calculation and was catched by the folllowing:

The following source:

def cvt(str: String) -> uint16[] {
  let size = str.size;
  var utf = uint16[](size);
  utf[size-1] = 0;
  return utf;
}

results in the error message:

BugTest3.tart:5: error: Type mismatch converting infixSubtract(size, 1)  from 
'{Result:iint8|int16|int32|int64|uint8|uint16|uint32|uint64|float|double|#consta
nt_int}' to 'int64'

If I introduce a new let value:

def cvt(str: String) -> uint16[] {
  let size = str.size;
  var utf = uint16[](size);
  let tmp = size-1;
  utf[tmp] = 0;
  return utf;
}

then the error is gone. Again, I think that both variants should be 
semantically identical.

BTW: Do you prefer such small code sequences or real test cases constructed 
 from Test class?

Original issue reported on code.google.com by kai.na...@gmail.com on 9 Dec 2010 at 5:08

GoogleCodeExporter commented 8 years ago
Small test cases are fine.

It may be a few days before I get a chance to work on these.

Original comment by viri...@gmail.com on 9 Dec 2010 at 7:09