Page 1 of 1

int8

PostPosted: Fri Oct 03, 2008 4:12 pm
by relez
If i have well understood int8 stands for sbyte.
Now, this code is ok:

Code: Select all
class Program
   def main is shared
      i08 as int8
      i08 = 127


but this is ko:

Code: Select all
class Program
   def main is shared
      i08 as int8
      i08 = -1


as it sends:
00049.cobra(4): error: Incompatible types. Cannot assign value of type int on th
e right to int8 on the left.

What am i missing? I obtain the same error with int16 while it's ok with int32 and int64.

Re: int8

PostPosted: Sat Oct 04, 2008 12:32 pm
by Charles
I tried it and this looks like a bug to me. The workaround is easy; cast the number to the type:
int08 = -1 to int8

Would you fill out a ticket by logging in at http://cobra-language.com/trac/cobra/report and then clicking New Ticket. Your login and password is the same as the forums.

Re: int8

PostPosted: Sat Oct 04, 2008 2:28 pm
by relez
Ok, created ticket #45.
Tk u.

Re: int8

PostPosted: Sat Oct 04, 2008 5:40 pm
by hopscc
This incorrect typing of numeric literals was also one of the reasons for ticket:29 (a workaround) and its subsequent (still pending) patch.

Re: int8

PostPosted: Sun Oct 05, 2008 2:14 pm
by Charles
Hmmm, nothing about the description of that ticket indicates to me that it addresses the typing of small integer literals...

Re: int8

PostPosted: Sun Oct 05, 2008 5:09 pm
by hopscc
read it again - size and sign - same as your workaround (casting).
It doesnt however address the real bug - that it shouldnt be necessary to equate the type exactly or cast to the receiving variable type.

Re: int8

PostPosted: Fri Oct 31, 2008 10:53 pm
by Charles
ticket:45 is fixed in changeset:1717

Re: int8

PostPosted: Sat Nov 01, 2008 1:35 pm
by relez
Updated. It works fine
Tk u ;)