atilaneves / dpp

Directly include C headers in D source code
Boost Software License 1.0
231 stars 31 forks source link

"Could not find namespaceless..." should cause UntranslatableException (?) #341

Closed denizzzka closed 1 year ago

denizzzka commented 1 year ago

UntranslatableException can be ignored if hard fail is unset. This is suitable for such cases with namespaceless

atilaneves commented 1 year ago

Test?

denizzzka commented 1 year ago

I don't know how to test this PR

"Namespaceless" behaviour itself is covered by tests in it.cpp.opaque

In fact is that this patch does not change any behaviour, it just removes implicit "hard fail" that was placed here for some reason. In normal mode if this exception occured it is not creates code and leaves an empty space as any other untranslable cursor

atilaneves commented 1 year ago

In fact is that this patch does not change any behaviour, it just removes implicit "hard fail" t

That's a change in behaviour. What code would trigger the change?

denizzzka commented 1 year ago

What code would trigger the change?

I added coverage for this PR. It fails on ~master, but works on this PR

For ~master coverage code returns:

     Running bin/all_tests -d -s it.cpp.misc.namespaceless
it.cpp.misc.namespaceless:
Cursor(Namespace, "ns", Type(Invalid, "")) CAN @ SourceRange("", 0:0, 0:0)
    Cursor(ClassDecl, "C1", Type(Record, "ns::C1")) CAN DEF @ SourceRange("/home/denizzz/Dev/dpp/tmp/unit-threaded/YYYYYYWo6Csm/hdr.hpp", 3:21, 7:22)
        Children: [Cursor(CXXAccessSpecifier, "", Type(Invalid, "")), Cursor(ClassDecl, "C2", Type(Record, "ns::C1::C2"))]
        Cursor(CXXAccessSpecifier, "", Type(Invalid, "")) CAN DEF @ SourceRange("/home/denizzz/Dev/dpp/tmp/unit-threaded/YYYYYYWo6Csm/hdr.hpp", 4:25, 4:32)
    Cursor(TypeAliasDecl, "_C2", Type(Typedef, "ns::_C2")) CAN DEF @ SourceRange("/home/denizzz/Dev/dpp/tmp/unit-threaded/YYYYYYWo6Csm/hdr.hpp", 13:21, 13:48)
        Children: [Cursor(TypeRef, "C1_Hidden", Type(Typedef, "C1_Hidden")), Cursor(TypeRef, "class ns::C1::C2", Type(Record, "ns::C1::C2"))]
        Underlying type: Type(Elaborated, "::C1_Hidden::C2")

Could not translate cursor Cursor(TypeAliasDecl, "_C2", Type(Typedef, "ns::_C2"))
msg: Could not find namespaceless 'C1::C2' in type '::C1_Hidden::C2'
sourceRange: SourceRange("/home/denizzz/Dev/dpp/tmp/unit-threaded/YYYYYYWo6Csm/hdr.hpp", 13:21, 13:48)
children: [Cursor(TypeRef, "C1_Hidden", Type(Typedef, "C1_Hidden")), Cursor(TypeRef, "class ns::C1::C2", Type(Record, "ns::C1::C2"))]

Could not translate cursor Cursor(Namespace, "ns", Type(Invalid, ""))
msg: Could not find namespaceless 'C1::C2' in type '::C1_Hidden::C2'
sourceRange: SourceRange("", 0:0, 0:0)
children: [Cursor(ClassDecl, "C1", Type(Record, "ns::C1")), Cursor(TypeAliasDecl, "_C2", Type(Typedef, "ns::_C2"))]

    object.Exception@source/dpp/translation/type/package.d(191): Could not find namespaceless 'C1::C2' in type '::C1_Hidden::C2'
----------------
source/dpp/translation/type/package.d:191 [0x56222088373b]
source/dpp/translation/type/package.d:153 [0x562220882f29]

[...]

../../.dub/packages/unit-threaded-2.1.3/unit-threaded/subpackages/runner/source/unit_threaded/runner/runner.d:22 [0x5622207631ec]
??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll() [0x7f4518b5a10c]
??:? _d_run_main2 [0x7f4518b59f26]
??:? _d_run_main [0x7f4518b59d7c]
/usr/lib/ldc/x86_64-linux-gnu/include/d/core/internal/entrypoint.d:42 [0x562220763271]
??:? [0x7f451878c189]
??:? __libc_start_main [0x7f451878c244]
??:? [0x5622207615b0]

Test it.cpp.misc.namespaceless failed.

Time taken: 74 ms, 29 μs, and 6 hnsecs
1 test(s) run, 1 failed, 6 hidden.

Tests failed!

Error Program exited with code 1