IDL→Rust codegen: a reopened IDL
|
| Files in translation unit | Blocks emitted | E0428 | Compiles |
|---|---|---|---|
| 1 (includes nothing) | 1 | 0 | yes |
| 2 | 2 | 1 | no |
| 3 | 3 | 2 | no |
| 4 | 4 | 3 | no |
The only file that compiles is the only one that includes nothing.
Impact
Any IDL using #include, or reopening a module within one file, yields output that does not compile. Since #include is the normal way to share common types across an IDL set, we expect this to affect most non-trivial users. Single-file, single-module IDL is unaffected.
Suggested fix
Group Definition::Module entries by name before emission and emit one pub mod block per distinct name, concatenating the members — mirroring the merge semantics IDL itself gives to a reopened module. Nested modules need the same treatment recursively.
A downstream post-processing step that merges the duplicate blocks textually is possible and is what we would fall back to, but it is fragile and we would rather not carry it.
We have not attempted a patch against the real codebase, preferring to test the unmodified published artefact. Reduced reproducer available on request.
Replies: 1 comment
|
Thank you, @swarm59, for the clear report and reproducer. You were right: reopening an IDL module could leave multiple module nodes in the generated representation, and the Rust backend then emitted duplicate The direct failure is fixed on Your report also led us considerably deeper than the original Rust compiler error. During the cross-backend audit, we found that ten code-generation backends had incomplete or missing handling for A second pass then uncovered another related problem: simply flattening module contents could make identically named types from different modules collide, or make a reference resolve to the type from the wrong module. The affected backends now use module-qualified, injective generated names and resolve cross-module references against the correct lexical scope. Tests cover nested and reopened modules, same-named types in different modules, and references crossing module boundaries. The complete public I am closing this discussion as fixed. If you still encounter duplicate modules, missing declarations, or an incorrect cross-module type reference on current Thank you again for providing the entry point to a much broader module and scope audit across the IDL compiler. |
Thank you, @swarm59, for the clear report and reproducer. You were right: reopening an IDL module could leave multiple module nodes in the generated representation, and the Rust backend then emitted duplicate
pub moddeclarations that failed with E0428.The direct failure is fixed on
maininbd7e592. Reopened modules are now merged into one semantic scope while preserving all declarations and their source information.Your report also led us considerably deeper than the original Rust compiler error. During the cross-backend audit, we found that ten code-generation backends had incomplete or missing handling for
Definition::Module. Instead of producing a visible duplicate, they could silen…