Forums

int8

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

int8

Postby relez » Fri Oct 03, 2008 4:12 pm

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.
relez
 
Posts: 69

Re: int8

Postby Charles » Sat Oct 04, 2008 12:32 pm

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.
Charles
 
Posts: 2513
Location: Los Angeles, CA

Re: int8

Postby relez » Sat Oct 04, 2008 2:28 pm

Ok, created ticket #45.
Tk u.
relez
 
Posts: 69

Re: int8

Postby hopscc » Sat Oct 04, 2008 5:40 pm

This incorrect typing of numeric literals was also one of the reasons for ticket:29 (a workaround) and its subsequent (still pending) patch.
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: int8

Postby Charles » Sun Oct 05, 2008 2:14 pm

Hmmm, nothing about the description of that ticket indicates to me that it addresses the typing of small integer literals...
Charles
 
Posts: 2513
Location: Los Angeles, CA

Re: int8

Postby hopscc » Sun Oct 05, 2008 5:09 pm

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.
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: int8

Postby Charles » Fri Oct 31, 2008 10:53 pm

ticket:45 is fixed in changeset:1717
Charles
 
Posts: 2513
Location: Los Angeles, CA

Re: int8

Postby relez » Sat Nov 01, 2008 1:35 pm

Updated. It works fine
Tk u ;)
relez
 
Posts: 69


Return to Discussion

Who is online

Users browsing this forum: No registered users and 12 guests

cron