ELENA-LANG / elena-lang

ELENA is a general-purpose language with late binding. It is multi-paradigm, combining features of functional and object-oriented programming. Rich set of tools are provided to deal with message dispatching : multi-methods, message qualifying, generic message handlers, run-time interfaces
https://elena-lang.github.io/
MIT License
236 stars 26 forks source link

long to int raise a index is out of range exception #335

Closed bencz closed 6 years ago

bencz commented 7 years ago

After implementation of uint type, this code cause a index is out of range exception

import system.
import extensions.

program =
[
    long rva := 339302427672l.
    int result := ((rva && 0FFFFFFFFh) toInt).
].
arakov commented 7 years ago

I will look at it

arakov commented 7 years ago

Quick fix will be to use long constant:

long rva := 339302427672l.

int result := ((rva && 4294967295l) toInt).

The problem that int32=0FFFFFFFFh should be correctly converted to int64=0FFFFFFFFFFFFFFFF and as a result you get the same number.

uint vs int is a long story :smile: I will fix it later after I finish multimethods implementation which will be huge change :smile:

arakov commented 6 years ago

The correct code is:

import system.
import extensions.

public program
[
    long rva := 339302427672l.
    int result := rva && 0FFFFFFFFh toUInt.
]