uqbar-project / wollok-ts

TypeScript based Wollok language implementation
GNU General Public License v3.0
20 stars 14 forks source link

Implementación de Object Mirror #224

Open fdodino opened 6 months ago

fdodino commented 6 months ago

Hoy quise ver si podía subir el coverage y llegué a ésto:

Creé un example.wlk con una clase muy tranqui:

class Capitan {
    var nombre
    var edad
}

Y al levantar el REPL: wollok repl example.wlk me tira error los 2 métodos que no están testeados de ObjectMirror:

wollok:example> const a = new Capitan(nombre = "Juan", edad = 23)
✓ 
wollok:example> const b = new ObjectMirror(target = a)
✗ Unknown reference ObjectMirror
wollok:example> import wollok.mirror.*
✓ 
wollok:example> const b = new ObjectMirror(target = a)
✓ 
wollok:example> b.instanceVariables()
✗ Evaluation Error!
  wollok.lang.EvaluationError wrapping TypeScript Error: Could not resolve reference to other or its a reference to void
wollok:example> b.instanceVariableFor("edad")
✗ Evaluation Error!
  wollok.lang.EvaluationError wrapping TypeScript Error: Could not resolve reference to other or its a reference to void

No es realmente prioritario pero está bueno considerarlo.

PalumboN commented 3 months ago

Creo que el bug está en la nativa que instancia la InstanceVariableMirror https://github.com/uqbar-project/wollok-ts/blob/a5cd696281ec78097a57877f5ed0ce3604ff96fc/src/wre/mirror.ts#L12-L19

Debería ser el target lo que le mande, no a él mismo:

return yield* this.instantiate('wollok.mirror.InstanceVariableMirror', {
        target: self.get('target')!,
        name,
      })