0 issues 1 contributor 4 branches 0 releases
Additions: 78 Deletions: 0 View patch
1 c.error('illegal format specifier `${fmt:c}` for type `${c.table.get_type_name(ftyp)}`',
2 node.fmt_poss[i])
3 }
4+ // v fmt doesn't format this correctly
5+ if
6+ c.table.final_sym(typ).kind in [.array, .array_fixed, .struct_, .interface_, .none_, .map, .sum_type]
7+ && fmt in [`E`, `F`, `G`, `e`, `f`, `g`, `d`, `u`, `x`, `X`, `o`, `c`, `p`, `b`] {
8+ c.error('illegal format specifier `${fmt:c}` for type `${c.table.get_type_name(ftyp)}`',
9+ node.fmt_poss[i])
10+ }
11 node.need_fmts[i] = fmt != c.get_default_fmt(ftyp, typ)
12 }
13 // check recursive str
14
1new file mode 100644
2+vlib/v/checker/tests/str_interpol_invalid_err.vv:8:13: error: illegal format specifier `x` for type `[]int`
3+ 6 |
4+ 7 | fn main() {
5+ 8 | _ = '${[1]:x}'
6+ | ^
7+ 9 | _ = '${[1]!:x}'
8+ 10 | _ = '${Foo{}:x}'
9+vlib/v/checker/tests/str_interpol_invalid_err.vv:9:14: error: illegal format specifier `x` for type `[1]int`
10+ 7 | fn main() {
11+ 8 | _ = '${[1]:x}'
12+ 9 | _ = '${[1]!:x}'
13+ | ^
14+ 10 | _ = '${Foo{}:x}'
15+ 11 | _ = '${[1]:f}'
16+vlib/v/checker/tests/str_interpol_invalid_err.vv:10:15: error: illegal format specifier `x` for type `Foo`
17+ 8 | _ = '${[1]:x}'
18+ 9 | _ = '${[1]!:x}'
19+ 10 | _ = '${Foo{}:x}'
20+ | ^
21+ 11 | _ = '${[1]:f}'
22+ 12 | _ := '${none:F}'
23+vlib/v/checker/tests/str_interpol_invalid_err.vv:11:13: error: illegal format specifier `f` for type `[]int`
24+ 9 | _ = '${[1]!:x}'
25+ 10 | _ = '${Foo{}:x}'
26+ 11 | _ = '${[1]:f}'
27+ | ^
28+ 12 | _ := '${none:F}'
29+ 13 | _ = '${{"a": "b"}:x}'
30+vlib/v/checker/tests/str_interpol_invalid_err.vv:12:15: error: illegal format specifier `F` for type `none`
31+ 10 | _ = '${Foo{}:x}'
32+ 11 | _ = '${[1]:f}'
33+ 12 | _ := '${none:F}'
34+ | ^
35+ 13 | _ = '${{"a": "b"}:x}'
36+ 14 | _ = '${Alias(Foo{}):x}'
37+vlib/v/checker/tests/str_interpol_invalid_err.vv:13:20: error: illegal format specifier `x` for type `map[string]string`
38+ 11 | _ = '${[1]:f}'
39+ 12 | _ := '${none:F}'
40+ 13 | _ = '${{"a": "b"}:x}'
41+ | ^
42+ 14 | _ = '${Alias(Foo{}):x}'
43+ 15 | _ = '${SumType(int(5)):o}'
44+vlib/v/checker/tests/str_interpol_invalid_err.vv:14:22: error: illegal format specifier `x` for type `Alias`
45+ 12 | _ := '${none:F}'
46+ 13 | _ = '${{"a": "b"}:x}'
47+ 14 | _ = '${Alias(Foo{}):x}'
48+ | ^
49+ 15 | _ = '${SumType(int(5)):o}'
50+ 16 | }
51+vlib/v/checker/tests/str_interpol_invalid_err.vv:15:25: error: illegal format specifier `o` for type `SumType`
52+ 13 | _ = '${{"a": "b"}:x}'
53+ 14 | _ = '${Alias(Foo{}):x}'
54+ 15 | _ = '${SumType(int(5)):o}'
55+ | ^
56+ 16 | }
57
1new file mode 100644
2+struct Foo {}
3+
4+type Alias = Foo
5+
6+type SumType = Alias | int
7+
8+fn main() {
9+ _ = '${[1]:x}'
10+ _ = '${[1]!:x}'
11+ _ = '${Foo{}:x}'
12+ _ = '${[1]:f}'
13+ _ := '${none:F}'
14+ _ = '${{"a": "b"}:x}'
15+ _ = '${Alias(Foo{}):x}'
16+ _ = '${SumType(int(5)):o}'
17+}
18