fix(interface): preserve operation item uniqueness

Disambiguate generated argument types when distinct operation names normalize to the same PascalCase form, and add the requested Number round-trip and collision regression coverage.
This commit is contained in:
2026-09-28 23:21:13 +09:00
parent 18ac8844b0
commit 3f94d48f04
3 changed files with 79 additions and 0 deletions
+38
View File
@@ -216,3 +216,41 @@ fn typed_dispatch_validates_decodes_invokes_encodes_and_validates() {
let unknown = CatalogDefinition::dispatch(&AcceptingCatalog, "missing", vec![]).unwrap_err();
assert!(matches!(unknown, DispatchError::UnknownOperation(name) if name == "missing"));
}
/// Operations whose distinct source names normalize to the same PascalCase.
#[interface]
pub trait DistinctOperations {
/// Returns the first item marker.
fn item(&self) -> OperationResult<String>;
/// Returns the underscored item marker.
fn item_(&self) -> OperationResult<String>;
}
struct DistinctImplementation;
impl DistinctOperations for DistinctImplementation {
fn item(&self) -> OperationResult<String> {
Ok("item".into())
}
fn item_(&self) -> OperationResult<String> {
Ok("item_".into())
}
}
#[test]
fn distinct_operation_names_always_generate_distinct_public_items() {
let descriptor = DistinctOperationsDefinition::descriptor();
assert_eq!(descriptor.operations[0].name, "item");
assert_eq!(descriptor.operations[1].name, "item_");
let first = DistinctOperationsDefinition::dispatch(&DistinctImplementation, "item", vec![])
.unwrap()
.unwrap();
let second = DistinctOperationsDefinition::dispatch(&DistinctImplementation, "item_", vec![])
.unwrap()
.unwrap();
assert_eq!(first, Value::String("item".into()));
assert_eq!(second, Value::String("item_".into()));
}