Rust printer: Statement.getBasichead() printed as 'return self' in both branches

Abierto
#196 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
50/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
java, rust
Área
compilers

Línea de trabajo

Start with the Rust translation of Statement.getBasichead() in the fernflower reproduction and trace how the Shared<Statement> field first is translated through recursive calls returning &Self. Compare the generated Rust with the Java branches and inspect build_continue_set and is_head_do_statement to understand the impact. Done means the translated else branch preserves the recursive call and the translation report identifies any remaining unsupported behavior.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug front-end:rust

On fernflower (test-oss/fernflower, translated with --translate rust), Statement.getBasichead() is printed with self in both branches:

public BasicBlockStatement getBasichead() {
  if (type == StatementType.BASIC_BLOCK) {
    return (BasicBlockStatement)this;
  }
  else {
    return first.getBasichead();
  }
}
pub fn get_basichead(&self) -> &Self {
    if self.r#type == StatementStatementType::BasicBlock {
        return self;
    } else {
        return self;
    }
}

It compiles, so rustc does not catch it, and the translation report has no message for these lines. The recursion into first is gone. Callers that build continue-sets from it (build_continue_set, is_head_do_statement) inherit the wrong result.

The setting:

  • Statement is the root of a closed hierarchy, and BasicBlockStatement is a member of it.
  • first is Option<crate::jrt::Shared<Statement<'a>>>.

A small reproduction with a plain field, then with a nullable field and a member cast (return (Leaf) this / return first.head()), prints the recursion correctly. So the trigger is probably the Shared handle, or the &Self return through it. It is not the cast.

Found while reviewing the printed bodies against the Java.

🤖 Generated with Claude Code

Lenguaje dominante
Java
Estrellas
1
Forks
1
Merge medio
48 min
PR fusionados (30 d)
2

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de CodeLaser/maddi

Todos los issues de CodeLaser/maddi

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.