Severity: medium (found stress-testing against Topologic, #79)
int and unsigned int both map to Mojo's Int (and presumably Rust's i64/Zig's equivalent). When a C++ class overloads a method by signedness only, both overloads survive into the emitted target with an identical signature — a guaranteed duplicate-definition compile error.
Repro (from github.com/wassimj/Topologic, TopologicCore/include/Bitwise.h):
class Bitwise {
public:
static int NOT(const int kArgument1);
static unsigned int NOT(const unsigned int kArgument1);
};
transpile --source cpp --target mojo on the flattened header+source emits:
struct Bitwise(Copyable, Movable):
def NOT(self, kArgument1: Int) -> Int:
return -kArgument1
def NOT(self, kArgument1: Int) -> Int:
return -kArgument1
Two methods with the identical (Int) -> Int signature in the same struct — Mojo (and Rust/Zig, which don't support overloading by signedness either) will reject this as a redefinition.
Fix direction
Detect same-name methods/functions in a struct/module whose parameter+return signatures collapse to identical target types after the int/unsigned int → single-int-type simplification, and either:
- rename the losing overload deterministically (e.g. suffix
_u/_unsigned), or
- refuse the construct (raise
UnsupportedConstruct) rather than silently emitting code that won't compile — consistent with this project's stated "refuse rather than emit wrong code" philosophy.
Found via corpus-testing PR (branch claude/repo-review-n4ylcz) which also fixed several parser-level gaps (export-macro handling, std::list shim, header-guard stripping) surfaced by the same corpus.
Severity: medium (found stress-testing against Topologic, #79)
intandunsigned intboth map to Mojo'sInt(and presumably Rust'si64/Zig's equivalent). When a C++ class overloads a method by signedness only, both overloads survive into the emitted target with an identical signature — a guaranteed duplicate-definition compile error.Repro (from
github.com/wassimj/Topologic,TopologicCore/include/Bitwise.h):transpile --source cpp --target mojoon the flattened header+source emits:Two methods with the identical
(Int) -> Intsignature in the same struct — Mojo (and Rust/Zig, which don't support overloading by signedness either) will reject this as a redefinition.Fix direction
Detect same-name methods/functions in a struct/module whose parameter+return signatures collapse to identical target types after the
int/unsigned int→ single-int-type simplification, and either:_u/_unsigned), orUnsupportedConstruct) rather than silently emitting code that won't compile — consistent with this project's stated "refuse rather than emit wrong code" philosophy.Found via corpus-testing PR (branch
claude/repo-review-n4ylcz) which also fixed several parser-level gaps (export-macro handling,std::listshim, header-guard stripping) surfaced by the same corpus.