Repository navigation
Description
Summary
Add missing tests for c_import surface stability: enum translation, allow-list cache keys, and collision mangling. These are implemented or partially implemented behaviors that need regression coverage.
Spec
§16.2 says generated c_import surfaces contain only real bindings and reports inexpressible gaps honestly (docs/with-specification.md:8131, docs/with-specification.md:8171). Constant/enum-like C declarations should become With constants/types where representable, and duplicate names from transitive includes are mangled with numeric suffixes (name_2, name_3) (docs/with-specification.md:8201). The importer allow-list for acknowledged untranslated symbols must affect cache identity so changing it cannot reuse stale generated bindings; this requirement is tracked in docs/requirements.md under 16.2.1.18.
Current state
Frontend.c_import_cache_key_frontend includes link libraries and allow_untranslated names in the cache key (src/compiler/Frontend.w:352). Omitted unallowed symbols produce directional diagnostics with an allow_untranslated suggestion (src/compiler/Frontend.w:471). CImport.w contains enum constant emission and collision mangling logic around enum constants (src/CImport.w:1753) and records emitted names to avoid collisions throughout import generation. The issue is missing test coverage for these surface contracts.
Implementation plan
- Add a header fixture with an enum and assert the generated/imported With surface exposes constants/variants with the expected names and values.
- Add a duplicate-name fixture through transitive includes or repeated declarations and assert numeric suffixing (
foo,foo_2) is deterministic. - Add a cache-key test for
allow_untranslated: import the same header once without an allow-list and once with one; assert the cache key/generated path differs or the second import does not reuse the first result. - Add a negative test that referencing an omitted symbol without allow-list produces the directional diagnostic already emitted by
Frontend.w. - Keep the tests local and deterministic; do not depend on system headers.
Test plan
Add test/behavior/behav_c_import_enum_surface.h and .w. Add test/behavior/behav_c_import_collision_mangling.h plus any included headers needed to force duplicate names. Add a compile/check test for allow_untranslated cache key behavior, possibly by setting WITH_CIMPORT_CACHE_EPOCH or inspecting generated cache metadata if the harness supports it.
Acceptance criteria
- C enum translation is covered.
- Duplicate imported names receive deterministic numeric suffixes under test.
allow_untranslatedparticipates in c_import cache identity under test.- Directional omitted-symbol diagnostics remain covered.
with build && with build :fixpoint && with build :testpass.
Dependencies
Related to #417 for omission manifest diagnostics and #418 for strict/selective import behavior.
Traceability
From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 16.1.1.10, 16.2.1.18, 16.2.1.26.
Activity
ehartford commentedon Jul 3, 2026
Closing the pinnable surface: C enum→constants (behav_c_import_enum_surface) + allow_untranslated (behav_c_import_allow_untranslated) covered (3628d82). Two sub-parts are NOT expressible as runnable .w fixtures and need harness mechanisms: cross-c_import collision mangling (_2 suffix, only observable via the internal dedup table) and cache-key participation (needs cache-metadata inspection). Flagged as harness gaps, not behavior gaps. §16.
test: coverage-sweep batch 5 (#485 #486 #487 #500 #505 #510)