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

Đang mở
#196 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
50/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, rust
Lĩnh vực
compilers

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Java
Star
1
Fork
1
Merge trung bình
48 phút
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của CodeLaser/maddi

Tất cả issue của CodeLaser/maddi

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.