uqbar-project / wollok

Wollok Programming Language
GNU General Public License v3.0
60 stars 16 forks source link

Unexpected wollok.lang.MessageNotUnderstoodException: Lazy values only support eval() #601

Closed mmatos closed 8 years ago

mmatos commented 8 years ago

Trying a simple example, I get this error:

wollok.lang.MessageNotUnderstoodException: Lazy values only support eval()
    at herenciaBending.MaestroAgua.esGroso() [file:/C:/Users/IBM_ADMIN/Documents/PdeP/wollok-win32.dev/workspace/Ejemplos/src/herenciaBending/herenciaBending.wlk]

With the the following code I'm only getting it from the test case and it works from the REPL, but trying different things I got it from the REPL as well. I honestly don't know the cause, I'm leaving code snippets of what I did to see if someone can make any sense of it:

In the wlk file

class MaestroAgua {

    var habilidad = 0

    constructor(unaHabilidad){
        habilidad = unaHabilidad
    }

    method poder(){
        return habilidad* 100
    }

    method esGroso(){
        return this.poderGroso() && this.habilidadGrosa()
    }

    method poderGroso(){
        return this.poder() > 1000
    }

    method habilidadGrosa(){
        return habilidad > 5
    }
 }

In the test file (also includes import statement and another test that uses poder() and works)

 object katara inherits MaestroAgua(50){}
 object soka inherits MaestroAgua(6){}

 test "un maestro agua es groso dependiendo de su poder y habilidad" {
    assert.that(katara.esGroso())
    assert.notThat(soka.esGroso())
 }

If instead of defining those 2 extra methods, I just define:

method esGroso(){
        return  this.poder() > 1000 && habilidad > 5
}

The error I get from the test case is: wollok.lang.Exception: Error evaluating line file:/C:/Users/IBM_ADMIN/Documents/PdeP/wollok-win32.dev/workspace/Ejemplos/src/herenciaBending/herenciaBending.wlk:[11]: habilidad > 5

But if I invert those conditions like this:

method esGroso(){
        return  habilidad > 5 && this.poder() > 1000  
}

The error is this one again:

wollok.lang.MessageNotUnderstoodException: Lazy values only support eval()
    at herenciaBending.MaestroAgua.esGroso() [file:/C:/Users/IBM_ADMIN/Documents/PdeP/wollok-win32.dev/workspace/Ejemplos/src/herenciaBending/herenciaBending.wlk]
    at herenciaBending.MaestroAgua.esGroso() [file:/C:/Users/IBM_ADMIN/Documents/PdeP/wollok-win32.dev/workspace/Ejemplos/src/herenciaBending/herenciaBending.wlk]
    at  [file:/C:/Users/IBM_ADMIN/Documents/PdeP/wollok-win32.dev/workspace/Ejemplos/src/herenciaBending/herenciaBending.wtest]

.. and I get it also from the REPL:

wollok.lang.MessageNotUnderstoodException: Lazy values only support eval()
    at herenciaBending.MaestroAgua.esGroso() [file:/C:/Users/IBM_ADMIN/Documents/PdeP/wollok-win32.dev/workspace/Ejemplos/src/herenciaBending/herenciaBending.wlk]
    at herenciaBending.MaestroAgua.esGroso() [file:/C:/Users/IBM_ADMIN/Documents/PdeP/wollok-win32.dev/workspace/Ejemplos/src/herenciaBending/herenciaBending.wlk]
    at  [file:/C:/Users/IBM_ADMIN/Documents/PdeP/wollok-win32.dev/workspace/Ejemplos/src/herenciaBending/__synthetic0.wpgm]
    at  [file:/C:/Users/IBM_ADMIN/Documents/PdeP/wollok-win32.dev/workspace/Ejemplos/src/herenciaBending/herenciaBending.wlk]
    at  [file:/C:/Users/IBM_ADMIN/Documents/PdeP/wollok-win32.dev/workspace/Ejemplos/src/herenciaBending/herenciaBending.wlk]
mmatos commented 8 years ago

BTW, the same code that I pasted here that would not run in the ecplise based runner worked just fine in Mumuki. It seems Mumuki is using an older version of Wollok than the latest stable version, so it might be related to a newer change

javierfernandes commented 8 years ago

This got fixed in 1.4.1 by #622