diff --git a/tests/unit/mod_private_type.jam b/tests/unit/mod_private_type.jam new file mode 100644 index 0000000..ffcd1db --- /dev/null +++ b/tests/unit/mod_private_type.jam @@ -0,0 +1,16 @@ +// Helper for test_private_type_signatures: a PRIVATE struct used in +// this module's own pub-fn signatures. Private types register under +// their qualified identity so these signatures resolve; importers can +// only touch the values opaquely (through the pub fns), never name the +// type. +const Inner = struct { + value: u32, +}; + +pub fn makeInner(v: u32) Inner { + return Inner { value: v }; +} + +pub fn readInner(i: Inner) u32 { + return i.value; +} diff --git a/tests/unit/test_private_type_signatures.jam b/tests/unit/test_private_type_signatures.jam new file mode 100644 index 0000000..19678a2 --- /dev/null +++ b/tests/unit/test_private_type_signatures.jam @@ -0,0 +1,15 @@ +// A module whose pub fns traffic in a PRIVATE struct. Private types +// were once never registered at all — the module's own signatures +// failed to resolve (`unknown module handle` on the compiler's own +// qualified identity) unless some other module happened to define a +// same-named type that collided into the same registry slot. They now +// register under their qualified identity; the importer passes the +// values through opaquely. (Privacy still holds: naming the type via a +// handle is rejected — pinned by the C++ namespace-access tests.) + +const { assert } = import("test"); +const { makeInner, readInner } = import("mod_private_type"); + +tfn privateTypeFlowsThroughPubFns() { + assert(readInner(makeInner(41)), 41); +}