Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override method (...) does not match the returned type from its superclass cuando hay returns ¿y/o? llaves en if/else #307

Open
felipecalvo opened this issue Nov 6, 2024 · 3 comments · May be fixed by #324
Labels
bug Something isn't working component: validator Linter / Validator good first issue Good for newcomers priority: medium A "should" issue, whenever we have the time to solve it

Comments

@felipecalvo
Copy link

felipecalvo commented Nov 6, 2024

Cuando una clase hace override de un método y agrega un if/else con returns y llaves, tira el error shouldMatchSuperclassReturnValue.

Sin el override, tira el warning de shouldUseOverrideKeyword pero compila y funciona.

Si evitamos el else y sólo dejamos el if, funciona sin errores. Lo mismo si definimos el método en una línea.

Gist con el código: https://gist.github.com/felipecalvo/97de96cb488519ae6ceec31849f85b61

imagen

cc @EmaSantoro @aleperaltabazas

@felipecalvo felipecalvo changed the title Override method (...) does not match the returned type from its superclass cuando hay returns en if/else Override method (...) does not match the returned type from its superclass cuando hay returns ¿y/o? llaves en if/else Nov 6, 2024
@PalumboN PalumboN transferred this issue from uqbar-project/wollok-language Nov 11, 2024
@PalumboN PalumboN added bug Something isn't working component: validator Linter / Validator priority: high This issue has high priority, it should be addressed first labels Nov 11, 2024
@PalumboN
Copy link
Contributor

Related #265

@PalumboN PalumboN added good first issue Good for newcomers priority: medium A "should" issue, whenever we have the time to solve it and removed priority: high This issue has high priority, it should be addressed first labels Nov 19, 2024
@MVitelli
Copy link
Contributor

@fdodino
Just started a PR with a possible fix.

The only case that is failing right now is:

class FilosofoRoto2 inherits Filosofo {
  override method iluminacion() {
    if (1 > 0) 3 else 5
  }
}

I need some advice in how to compare a Return type sentence against a Literal.

In the other hand, I don't know if it's the scope of this issue to tackle nested if-else conditions.

@fdodino
Copy link
Contributor

fdodino commented Dec 25, 2024

@fdodino Just started a PR with a possible fix.

The only case that is failing right now is:

class FilosofoRoto2 inherits Filosofo {
  override method iluminacion() {
    if (1 > 0) 3 else 5
  }
}

I need some advice in how to compare a Return type sentence against a Literal.

In the other hand, I don't know if it's the scope of this issue to tackle nested if-else conditions.

Buenísimo, en este caso igual es raro que ese if no esté devolviendo nada. Vos decís que ahora el único caso que falla es el que comentás arriba, por ahí yo empezaría armando un PR para language de los casos que reportó Felipe. Y después hay que mirar qué tipo de sentencia está involucrada tirando warning o error, para lo cual lo mejor es ir imprimiendo el AST y el contenido de cada nodo. Hay una tablita de cómo considerar que se devuelve un valor o no, medio falopa, pero que ataja varios casos...

Lo ideal es ver si armamos una juntada para pairearlo, pasa que este martes fue 24 y el que viene es 31/12. Pero hablemos...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component: validator Linter / Validator good first issue Good for newcomers priority: medium A "should" issue, whenever we have the time to solve it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants