1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//! Bug reproducer for ComponentModel tuple struct limitation
//!
//! # Root Cause
//!
//! ComponentModel macro explicitly rejects tuple structs with error "ComponentModel requires named fields"
//! at `component_model.rs:37`. The implementation uses pattern matching on `syn::Fields::Named`
//! and returns `syn_err!` for all other field types (Unit, Unnamed).
//!
//! # Why Not Caught
//!
//! No test coverage existed for ComponentModel with tuple structs. The limitation is intentional
//! in the implementation but completely undocumented in the public API (src/lib.rs lines 544-591).
//! Users attempting to use ComponentModel with tuple structs get a compile error with no prior
//! warning from documentation.
//!
//! # Fix Applied
//!
//! DOCUMENTATION FIX NEEDED (not yet applied):
//! Add "Limitations" section to ComponentModel documentation in src/lib.rs explaining:
//! - Only works with named-field structs
//! - Does not support tuple structs (use ComponentAssign/ComponentFrom instead)
//! - Does not support unit structs
//! - Does not support enums or unions
//!
//! Example documentation addition:
//! ```markdown
//! ## Limitations
//!
//! ComponentModel only supports structs with named fields:
//!
//! ```rust,compile_fail
//! #[derive(ComponentModel)]
//! struct Point(i32, i32); // ERROR: ComponentModel requires named fields
//! ```
//!
//! For tuple structs, use ComponentAssign or ComponentFrom instead.
//! ```
//!
//! # Prevention
//!
//! - Add comprehensive test matrix for all derive macros covering struct types (named, tuple, unit)
//! - Document limitations prominently in macro documentation
//! - Consider improving error message to suggest alternatives: "ComponentModel requires named fields. For tuple structs, use #[derive(ComponentFrom, Assign)] instead."
//! - Add compile_fail doctests showing unsupported cases
//!
//! # Pitfall
//!
//! ComponentModel documentation (src/lib.rs:544-591) shows only named-field struct examples,
//! giving no indication that tuple structs are unsupported. Other macros (ComponentFrom,
//! ComponentAssign) DO support tuple structs, creating inconsistent user expectations.
//!
//! Users naturally expect that if ComponentFrom works with tuple structs, ComponentModel (which
//! claims to be a "unified derive") should also work with them.
// test_kind: bug_reproducer(issue-004)