| 1 | // Test for issue #26271: v fmt fails on mutually exclusive $if blocks with duplicate method definitions |
| 2 | module main |
| 3 | |
| 4 | struct MyType { |
| 5 | value int |
| 6 | } |
| 7 | |
| 8 | $if foo ? { |
| 9 | pub fn (x MyType) str() string { |
| 10 | return 'foo mode' |
| 11 | } |
| 12 | } $else { |
| 13 | pub fn (x MyType) str() string { |
| 14 | return 'normal mode' |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | $if bar ? { |
| 19 | fn (m MyType) debug() string { |
| 20 | return 'bar debug' |
| 21 | } |
| 22 | } $else $if baz ? { |
| 23 | fn (m MyType) debug() string { |
| 24 | return 'baz debug' |
| 25 | } |
| 26 | } $else { |
| 27 | fn (m MyType) debug() string { |
| 28 | return 'default debug' |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | fn main() { |
| 33 | t := MyType{42} |
| 34 | println(t.str()) |
| 35 | } |
| 36 | |