| 1 | module main |
| 2 | |
| 3 | fn make_empty() map[string]int { |
| 4 | return {} |
| 5 | } |
| 6 | |
| 7 | fn main() { |
| 8 | // Empty shorthand map literal `{}` should lower to a correct runtime map constructor. |
| 9 | mut m := make_empty() |
| 10 | key1 := 'abc' |
| 11 | key2 := key1.clone() // Ensure key equality is based on string content, not pointer identity. |
| 12 | m[key1] = 123 |
| 13 | println(m[key2]) |
| 14 | println(m['missing']) |
| 15 | |
| 16 | // Typed empty map init should also lower to a runtime map constructor. |
| 17 | mut m2 := map[string]int{} |
| 18 | m2['x'] = 7 |
| 19 | println(m2['x']) |
| 20 | } |
| 21 | |