autocxx icon indicating copy to clipboard operation
autocxx copied to clipboard

"in destructor name" bug

Open adetaylor opened this issue 2 years ago • 3 comments

namespace rust {
inline namespace a {
class Str {
public:
  ~Str();
};
} // namespace a
} // namespace rust

adetaylor avatar May 05 '22 03:05 adetaylor

The same problem appears when the test is:

#[test]
fn test_issue_1097() {
    let hdr = indoc! {"
        #include <cxx.h>
    "};
    run_generate_all_test(hdr);
}

so the minimization is plausible.

Somehow the known_types logic is causing us to generate arg0->~rust::Str();, because any other permutation of names gets the usual arg0->~StrA(); which is not buggy.

So, probably the correct solution is to just avoid generating any APIs for things in known_types even if we're in generate_all mode. Or something along those lines.

adetaylor avatar Sep 14 '22 19:09 adetaylor

The problem reproduces with this alternative change and test case...

diff --git a/engine/src/known_types.rs b/engine/src/known_types.rs
index 3850db24..9379e2c4 100644
--- a/engine/src/known_types.rs
+++ b/engine/src/known_types.rs
@@ -413,6 +413,14 @@ fn create_type_database() -> TypeDatabase {
         true,
         false,
     ));
+    db.insert(TypeDetails::new(
+        "str",
+        "a::Fish",
+        Behavior::RustStr,
+        None,
+        true,
+        false,
+    ));
     db.insert(TypeDetails::new(
         "String",
         "rust::String",
diff --git a/integration-tests/tests/integration_test.rs b/integration-tests/tests/integration_test.rs
index 8aa41360..15134c5d 100644
--- a/integration-tests/tests/integration_test.rs
+++ b/integration-tests/tests/integration_test.rs
@@ -11423,6 +11423,27 @@ fn test_issue_1097() {
     run_generate_all_test(hdr);
 }
 
+#[test]
+fn test_issue_1097b() {
+    let hdr = indoc! {"
+        namespace a {
+        class Fish {
+        public:
+          ~Fish();
+        };
+        inline namespace b {
+        class Fish {
+        public:
+          ~Fish();
+        };
+        }
+        }
+    "};
+    run_generate_all_test(hdr);
+}
+
+#[test]
+
 #[test]
 fn test_issue_1098a() {
     let hdr = indoc! {"

adetaylor avatar Sep 14 '22 20:09 adetaylor

The work in #1264 might help/change this a bit.

adetaylor avatar Apr 02 '23 02:04 adetaylor