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

Hanging the code after unsuccessful **if:is** statement #661

Closed arakov closed 5 months ago

arakov commented 5 months ago

Describe the bug In the following code the program is not terminated correctly. The code works correctly till the end but the program hangs at the end.

To Reproduce

import extensions;

class IntWrapper
{ 
    int value;

    constructor(int value) 
    {
       this value := value 
    }

    int cast()
       = value;  
}

class MyClass
{
    add(int n)
    {
        console.printLine("add int:(",n,")")
    }

    add(string s)
    {
        console.printLine("add literal:(",s,")")
    }

    add(o)
    {
        if (o; is int n) {
           ^ self.add(n);
        };

        console.printLine("unsupported")
    }
}

public program()
{
    var o := new MyClass();
    var wrapper := new IntWrapper(4);

    o.add("string");
    o.add(2);
    o.add(wrapper);
    o.add(2.3);  // when this line is commented, the code works correctly and ends without a problem
}

Expected behavior The code must end without hanging indefinitely

arakov commented 5 months ago

Fixed in ELENA 6.1.2