v2 / vlib / v / parser / map_init_fmt_regression_test.v
21 lines · 18 sloc · 491 bytes · e2de04c1ccbab83adb610d1af59e04956a010f76
Raw
1import v.ast
2import v.parser
3import v.pref
4
5fn test_typed_map_init_is_rejected_in_fmt_mode() {
6 source_text := 'module main
7
8const c_cap = 10
9
10fn main() {
11 _ := map[string][]u8{cap: c_cap}
12}
13'
14 mut table := ast.new_table()
15 prefs := &pref.Preferences{
16 is_fmt: true
17 output_mode: .silent
18 }
19 prog := parser.parse_text(source_text, '', mut table, .skip_comments, prefs)
20 assert prog.errors.any(it.message == '`}` expected; explicit `map` initialization does not support parameters')
21}
22