diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd2913bca4..87c0852618 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -846,7 +846,9 @@ jobs: - name: Install zzuf run: sudo apt install -qq zzuf - name: Build local v - run: make -j4 + run: | + make -j4 + ./v -g cmd/tools/vtest-parser.v - name: Run test-parser over fuzzed files run: | zzuf -R '\x00-\x20\x7f-\xff' -r0.01 < examples/hello_world.v > examples/hello_world_fuzz.v diff --git a/examples/2048/2048.v b/examples/2048/2048.v index 094428be19..16b5718839 100644 --- a/examples/2048/2048.v +++ b/examples/2048/2048.v @@ -16,7 +16,7 @@ mut: board Board undo []Undo atickers [4][4]int - state GameState = .play + state GameState = .play tile_format TileFormat = .normal moves int perf &Perf = 0 @@ -47,7 +47,7 @@ struct Theme { } const ( - themes = [ + themes = [ &Theme{ bg_color: gx.rgb(250, 248, 239) padding_color: gx.rgb(143, 130, 119) @@ -55,18 +55,18 @@ const ( game_over_color: gx.rgb(190, 50, 50) text_color: gx.black tile_colors: [ - gx.rgb(205, 193, 180), // Empty / 0 tile - gx.rgb(238, 228, 218), // 2 - gx.rgb(237, 224, 200), // 4 - gx.rgb(242, 177, 121), // 8 - gx.rgb(245, 149, 99), // 16 - gx.rgb(246, 124, 95), // 32 - gx.rgb(246, 94, 59), // 64 - gx.rgb(237, 207, 114), // 128 - gx.rgb(237, 204, 97), // 256 - gx.rgb(237, 200, 80), // 512 - gx.rgb(237, 197, 63), // 1024 - gx.rgb(237, 194, 46), // 2048 + gx.rgb(205, 193, 180), /* Empty / 0 tile */ + gx.rgb(238, 228, 218), /* 2 */ + gx.rgb(237, 224, 200), /* 4 */ + gx.rgb(242, 177, 121), /* 8 */ + gx.rgb(245, 149, 99), /* 16 */ + gx.rgb(246, 124, 95), /* 32 */ + gx.rgb(246, 94, 59), /* 64 */ + gx.rgb(237, 207, 114), /* 128 */ + gx.rgb(237, 204, 97), /* 256 */ + gx.rgb(237, 200, 80), /* 512 */ + gx.rgb(237, 197, 63), /* 1024 */ + gx.rgb(237, 194, 46), /* 2048 */ ] }, &Theme{ @@ -149,7 +149,7 @@ struct Undo { } struct TileLine { - ypos int + ypos int mut: field [5]int points int @@ -351,7 +351,8 @@ fn (mut b Board) is_game_over() bool { if (x > 0 && fidx == b.field[y][x - 1]) || (x < 4 - 1 && fidx == b.field[y][x + 1]) || (y > 0 && fidx == b.field[y - 1][x]) || - (y < 4 - 1 && fidx == b.field[y + 1][x]) { + (y < 4 - 1 && fidx == b.field[y + 1][x]) + { // there are remaining merges return false } @@ -623,8 +624,8 @@ fn (app &App) draw() { app.gg.draw_text(ww / 2, (m * 4 / 10) + ypad, 'Game Over', app.label_format(.game_over)) f := app.label_format(.tile) msg := $if android { 'Tap to restart' } $else { 'Press `r` to restart' } - app.gg.draw_text(ww / 2, (m * 6 / 10) + ypad, msg, { - f | + app.gg.draw_text(ww / 2, (m * 6 / 10) + ypad, msg, gx.TextCfg{ + ...f color: gx.white size: f.size * 3 / 4 }) @@ -649,7 +650,8 @@ fn (app &App) draw_tiles() { toffset := app.ui.tile_size + app.ui.padding_size tiles_size := min(app.ui.window_width, app.ui.window_height) - app.ui.border_size * 2 // Draw the padding around the tiles - app.gg.draw_rounded_rect(xstart, ystart, tiles_size / 2, tiles_size / 2, tiles_size / 24, app.theme.padding_color) + app.gg.draw_rounded_rect(xstart, ystart, tiles_size / 2, tiles_size / 2, tiles_size / 24, + app.theme.padding_color) // Draw the actual tiles for y in 0 .. 4 { for x in 0 .. 4 { @@ -670,8 +672,8 @@ fn (app &App) draw_tiles() { xpos := xoffset + tw / 2 ypos := yoffset + th / 2 mut fmt := app.label_format(.tile) - fmt = { - fmt | + fmt = gx.TextCfg{ + ...fmt size: int(f32(fmt.size - 1) / animation_length * anim_size) } match app.tile_format { @@ -685,16 +687,16 @@ fn (app &App) draw_tiles() { app.gg.draw_text(xpos, ypos, '2', fmt) fs2 := int(f32(fmt.size) * 0.67) app.gg.draw_text(xpos + app.ui.tile_size / 10, ypos - app.ui.tile_size / 8, - '$tidx', { - fmt | + '$tidx', gx.TextCfg{ + ...fmt size: fs2 align: gx.HorizontalAlign.left }) } .shifts { fs2 := int(f32(fmt.size) * 0.6) - app.gg.draw_text(xpos, ypos, '2<<${tidx - 1}', { - fmt | + app.gg.draw_text(xpos, ypos, '2<<${tidx - 1}', gx.TextCfg{ + ...fmt size: fs2 }) } @@ -951,7 +953,7 @@ fn main() { window_title_ = 'canvas' } app.perf = &Perf{} - app.gg = gg.new_context({ + app.gg = gg.new_context( bg_color: app.theme.bg_color width: default_window_width height: default_window_height @@ -963,6 +965,6 @@ fn main() { init_fn: init user_data: app font_path: font_path - }) + ) app.gg.run() } diff --git a/examples/term.ui/term_drawing.v b/examples/term.ui/term_drawing.v index d96ef6f747..c6b91b2a9c 100644 --- a/examples/term.ui/term_drawing.v +++ b/examples/term.ui/term_drawing.v @@ -190,17 +190,17 @@ fn event(event &tui.Event, x voidptr) { match event.code { .f1, ._1 { oevent := *event - nevent := { oevent | button: tui.MouseButton.left, x: app.mouse_pos.x , y: app.mouse_pos.y } + nevent := tui.Event{ ...oevent, button: tui.MouseButton.left, x: app.mouse_pos.x , y: app.mouse_pos.y } app.paint(nevent) } .f2, ._2 { oevent := *event - nevent := { oevent | button: tui.MouseButton.right, x: app.mouse_pos.x , y: app.mouse_pos.y } + nevent := tui.Event{ ...oevent, button: tui.MouseButton.right, x: app.mouse_pos.x , y: app.mouse_pos.y } app.paint(nevent) } .space { oevent := *event - nevent := { oevent | button: tui.MouseButton.middle, x: app.mouse_pos.x , y: app.mouse_pos.y } + nevent := tui.Event{ ...oevent, button: tui.MouseButton.middle, x: app.mouse_pos.x , y: app.mouse_pos.y } app.paint(nevent) } .j, .down { diff --git a/vlib/net/smtp/smtp.v b/vlib/net/smtp/smtp.v index 5e65085594..4e78c78801 100644 --- a/vlib/net/smtp/smtp.v +++ b/vlib/net/smtp/smtp.v @@ -88,8 +88,8 @@ pub fn (mut c Client) send(config Mail) ? { c.send_mailfrom(from) or { return error('Sending mailfrom failed') } c.send_mailto(config.to) or { return error('Sending mailto failed') } c.send_data() or { return error('Sending mail data failed') } - c.send_body({ - config | + c.send_body(Mail{ + ...config from: from }) or { return error('Sending mail body failed') } } diff --git a/vlib/net/smtp/smtp_test.v b/vlib/net/smtp/smtp_test.v index 769dd9441c..85f27ffbee 100644 --- a/vlib/net/smtp/smtp_test.v +++ b/vlib/net/smtp/smtp_test.v @@ -44,24 +44,23 @@ fn test_smtp() { return } assert true - // client.send({ send_cfg | body_type: .html, body: '

HTML V email!

' }) or { assert false return } - client.send({ - send_cfg | + client.send(smtp.Mail{ + ...send_cfg from: 'alexander@vlang.io' }) or { assert false return } - client.send({ - send_cfg | + client.send(smtp.Mail{ + ...send_cfg cc: 'alexander@vlang.io,joe@vlang.io' bcc: 'spytheman@vlang.io' }) or { assert false return } - client.send({ - send_cfg | + client.send(smtp.Mail{ + ...send_cfg date: time.now().add_days(1000) }) or { assert false diff --git a/vlib/term/ui/termios_nix.c.v b/vlib/term/ui/termios_nix.c.v index 226876d737..26160b6891 100644 --- a/vlib/term/ui/termios_nix.c.v +++ b/vlib/term/ui/termios_nix.c.v @@ -274,8 +274,8 @@ fn single_char(buf string) &Event { // special handling for `ctrl + letter` // TODO: Fix assoc in V and remove this workaround :/ - // 1 ... 26 { event = { event | code: KeyCode(96 | ch), modifiers: ctrl } } - // 65 ... 90 { event = { event | code: KeyCode(32 | ch), modifiers: shift } } + // 1 ... 26 { event = Event{ ...event, code: KeyCode(96 | ch), modifiers: ctrl } } + // 65 ... 90 { event = Event{ ...event, code: KeyCode(32 | ch), modifiers: shift } } // The bit `or`s here are really just `+`'s, just written in this way for a tiny performance improvement @@ -330,7 +330,6 @@ fn escape_sequence(buf_ string) (&Event, int) { if buf.len == 1 { c := single_char(buf) - // return { c | modifiers: c.modifiers | alt }, 2 return &Event{ typ: c.typ diff --git a/vlib/time/time.v b/vlib/time/time.v index 82f6ae504f..3e0ffa24d8 100644 --- a/vlib/time/time.v +++ b/vlib/time/time.v @@ -158,8 +158,8 @@ pub fn new_time(t Time) Time { tm_year: t.year - 1900 } utime := u64(make_unix_time(tt)) - return { - t | + return Time{ + ...t unix: utime } } diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index d460a61a13..495ed1a28b 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -3648,9 +3648,9 @@ fn (mut c Checker) comptime_call(mut node ast.ComptimeCall) table.Type { } if node.is_vweb { // TODO assoc parser bug - pref := *c.pref - pref2 := { - pref | + pref_ := *c.pref + pref2 := pref.Preferences{ + ...pref_ is_vweb: true } mut c2 := new_checker(c.table, pref2) diff --git a/vlib/v/compiler_errors_test.v b/vlib/v/compiler_errors_test.v index 6c9977850a..399062aeb2 100644 --- a/vlib/v/compiler_errors_test.v +++ b/vlib/v/compiler_errors_test.v @@ -40,12 +40,14 @@ fn test_all() { os.chdir(vroot) checker_dir := 'vlib/v/checker/tests' parser_dir := 'vlib/v/parser/tests' + scanner_dir := 'vlib/v/scanner/tests' module_dir := '$checker_dir/modules' global_dir := '$checker_dir/globals' run_dir := '$checker_dir/run' // checker_tests := get_tests_in_dir(checker_dir, false) parser_tests := get_tests_in_dir(parser_dir, false) + scanner_tests := get_tests_in_dir(scanner_dir, false) global_tests := get_tests_in_dir(global_dir, false) module_tests := get_tests_in_dir(module_dir, true) run_tests := get_tests_in_dir(run_dir, false) @@ -53,6 +55,7 @@ fn test_all() { mut tasks := []TaskDescription{} tasks.add(vexe, parser_dir, '-prod', '.out', parser_tests, false) tasks.add(vexe, checker_dir, '-prod', '.out', checker_tests, false) + tasks.add(vexe, scanner_dir, '-prod', '.out', scanner_tests, false) tasks.add(vexe, checker_dir, '-d mysymbol run', '.mysymbol.run.out', ['custom_comptime_define_error.vv'], false) tasks.add(vexe, checker_dir, '-d mydebug run', '.mydebug.run.out', ['custom_comptime_define_if_flag.vv'], diff --git a/vlib/v/parser/pratt.v b/vlib/v/parser/pratt.v index 529451cf0d..ad149ee2a3 100644 --- a/vlib/v/parser/pratt.v +++ b/vlib/v/parser/pratt.v @@ -369,13 +369,11 @@ fn (mut p Parser) infix_expr(left ast.Expr) ast.Expr { p.or_is_handled = true p.register_auto_import('sync') } - // mut typ := p. - // println('infix op=$op.str()') precedence := p.tok.precedence() mut pos := p.tok.position() if left.position().line_nr < pos.line_nr { - pos = { - pos | + pos = token.Position{ + ...pos line_nr: left.position().line_nr } } diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index 39a62732ec..0c1e258fe8 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -212,12 +212,12 @@ fn (mut s Scanner) ident_bin_number() string { mut first_wrong_digit := `\0` start_pos := s.pos s.pos += 2 // skip '0b' - if s.text[s.pos] == num_sep { + if s.pos < s.text.len && s.text[s.pos] == num_sep { s.error('separator `_` is only valid between digits in a numeric literal') } for s.pos < s.text.len { c := s.text[s.pos] - if c == num_sep && s.text[s.pos + 1] == num_sep { + if c == num_sep && s.text[s.pos - 1] == num_sep { s.error('cannot use `_` consecutively') } if !c.is_bin_digit() && c != num_sep { @@ -232,6 +232,7 @@ fn (mut s Scanner) ident_bin_number() string { s.pos++ } if s.text[s.pos - 1] == num_sep { + s.pos-- s.error('cannot use `_` at the end of a numeric literal') } else if start_pos + 2 == s.pos { s.pos-- // adjust error position @@ -254,12 +255,12 @@ fn (mut s Scanner) ident_hex_number() string { return '0x' } s.pos += 2 // skip '0x' - if s.text[s.pos] == num_sep { + if s.pos < s.text.len && s.text[s.pos] == num_sep { s.error('separator `_` is only valid between digits in a numeric literal') } for s.pos < s.text.len { c := s.text[s.pos] - if c == num_sep && s.text[s.pos + 1] == num_sep { + if c == num_sep && s.text[s.pos - 1] == num_sep { s.error('cannot use `_` consecutively') } if !c.is_hex_digit() && c != num_sep { @@ -274,6 +275,7 @@ fn (mut s Scanner) ident_hex_number() string { s.pos++ } if s.text[s.pos - 1] == num_sep { + s.pos-- s.error('cannot use `_` at the end of a numeric literal') } else if start_pos + 2 == s.pos { s.pos-- // adjust error position @@ -293,12 +295,12 @@ fn (mut s Scanner) ident_oct_number() string { mut first_wrong_digit := `\0` start_pos := s.pos s.pos += 2 // skip '0o' - if s.text[s.pos] == num_sep { + if s.pos < s.text.len && s.text[s.pos] == num_sep { s.error('separator `_` is only valid between digits in a numeric literal') } for s.pos < s.text.len { c := s.text[s.pos] - if c == num_sep && s.text[s.pos + 1] == num_sep { + if c == num_sep && s.text[s.pos - 1] == num_sep { s.error('cannot use `_` consecutively') } if !c.is_oct_digit() && c != num_sep { @@ -313,6 +315,7 @@ fn (mut s Scanner) ident_oct_number() string { s.pos++ } if s.text[s.pos - 1] == num_sep { + s.pos-- s.error('cannot use `_` at the end of a numeric literal') } else if start_pos + 2 == s.pos { s.pos-- // adjust error position @@ -334,7 +337,7 @@ fn (mut s Scanner) ident_dec_number() string { // scan integer part for s.pos < s.text.len { c := s.text[s.pos] - if c == num_sep && s.text[s.pos + 1] == num_sep { + if c == num_sep && s.text[s.pos - 1] == num_sep { s.error('cannot use `_` consecutively') } if !c.is_digit() && c != num_sep { @@ -349,6 +352,7 @@ fn (mut s Scanner) ident_dec_number() string { s.pos++ } if s.text[s.pos - 1] == num_sep { + s.pos-- s.error('cannot use `_` at the end of a numeric literal') } mut call_method := false // true for, e.g., 5.str(), 5.5.str(), 5e5.str() @@ -554,12 +558,12 @@ fn (mut s Scanner) text_scan() token.Token { } else { s.is_started = true } - if s.pos >= s.text.len { - return s.end_of_file() - } if !s.is_inside_string { s.skip_whitespace() } + if s.pos >= s.text.len { + return s.end_of_file() + } // End of $var, start next string if s.is_inter_end { if s.text[s.pos] == s.quote { diff --git a/vlib/v/scanner/tests/bin_consecutively_separator_err.out b/vlib/v/scanner/tests/bin_consecutively_separator_err.out new file mode 100644 index 0000000000..cfb8641df8 --- /dev/null +++ b/vlib/v/scanner/tests/bin_consecutively_separator_err.out @@ -0,0 +1,5 @@ +vlib/v/scanner/tests/bin_consecutively_separator_err.vv:2:9: error: separator `_` is only valid between digits in a numeric literal + 1 | fn main() { + 2 | _ := 0b_20 + | ^ + 3 | } diff --git a/vlib/v/scanner/tests/bin_consecutively_separator_err.vv b/vlib/v/scanner/tests/bin_consecutively_separator_err.vv new file mode 100644 index 0000000000..8328aab1aa --- /dev/null +++ b/vlib/v/scanner/tests/bin_consecutively_separator_err.vv @@ -0,0 +1,3 @@ +fn main() { + _ := 0b_20 +} diff --git a/vlib/v/scanner/tests/bin_separator_in_front_err.out b/vlib/v/scanner/tests/bin_separator_in_front_err.out new file mode 100644 index 0000000000..b7f024fbd7 --- /dev/null +++ b/vlib/v/scanner/tests/bin_separator_in_front_err.out @@ -0,0 +1,5 @@ +vlib/v/scanner/tests/bin_separator_in_front_err.vv:2:9: error: separator `_` is only valid between digits in a numeric literal + 1 | fn main() { + 2 | _ := 0b_20 + | ^ + 3 | } diff --git a/vlib/v/scanner/tests/bin_separator_in_front_err.vv b/vlib/v/scanner/tests/bin_separator_in_front_err.vv new file mode 100644 index 0000000000..8328aab1aa --- /dev/null +++ b/vlib/v/scanner/tests/bin_separator_in_front_err.vv @@ -0,0 +1,3 @@ +fn main() { + _ := 0b_20 +} diff --git a/vlib/v/scanner/tests/dec_consecutively_separator_err.out b/vlib/v/scanner/tests/dec_consecutively_separator_err.out new file mode 100644 index 0000000000..d08deda815 --- /dev/null +++ b/vlib/v/scanner/tests/dec_consecutively_separator_err.out @@ -0,0 +1,5 @@ +vlib/v/scanner/tests/dec_consecutively_separator_err.vv:2:7: error: undefined ident: `_20` + 1 | fn main() { + 2 | _ := _20 + | ~~~ + 3 | } diff --git a/vlib/v/scanner/tests/dec_consecutively_separator_err.vv b/vlib/v/scanner/tests/dec_consecutively_separator_err.vv new file mode 100644 index 0000000000..7f35a5b99e --- /dev/null +++ b/vlib/v/scanner/tests/dec_consecutively_separator_err.vv @@ -0,0 +1,3 @@ +fn main() { + _ := _20 +} diff --git a/vlib/v/scanner/tests/hex_consecutively_separator_err.out b/vlib/v/scanner/tests/hex_consecutively_separator_err.out new file mode 100644 index 0000000000..4d65ad3abb --- /dev/null +++ b/vlib/v/scanner/tests/hex_consecutively_separator_err.out @@ -0,0 +1,5 @@ +vlib/v/scanner/tests/hex_consecutively_separator_err.vv:2:9: error: separator `_` is only valid between digits in a numeric literal + 1 | fn main() { + 2 | _ := 0x_20 + | ^ + 3 | } diff --git a/vlib/v/scanner/tests/hex_consecutively_separator_err.vv b/vlib/v/scanner/tests/hex_consecutively_separator_err.vv new file mode 100644 index 0000000000..5c78321991 --- /dev/null +++ b/vlib/v/scanner/tests/hex_consecutively_separator_err.vv @@ -0,0 +1,3 @@ +fn main() { + _ := 0x_20 +} diff --git a/vlib/v/scanner/tests/hex_separator_in_front_err.out b/vlib/v/scanner/tests/hex_separator_in_front_err.out new file mode 100644 index 0000000000..5b47ffb32b --- /dev/null +++ b/vlib/v/scanner/tests/hex_separator_in_front_err.out @@ -0,0 +1,5 @@ +vlib/v/scanner/tests/hex_separator_in_front_err.vv:2:9: error: separator `_` is only valid between digits in a numeric literal + 1 | fn main() { + 2 | _ := 0o_20 + | ^ + 3 | } diff --git a/vlib/v/scanner/tests/hex_separator_in_front_err.vv b/vlib/v/scanner/tests/hex_separator_in_front_err.vv new file mode 100644 index 0000000000..87709cdca1 --- /dev/null +++ b/vlib/v/scanner/tests/hex_separator_in_front_err.vv @@ -0,0 +1,3 @@ +fn main() { + _ := 0o_20 +} diff --git a/vlib/v/scanner/tests/oct_consecutively_separator_err.out b/vlib/v/scanner/tests/oct_consecutively_separator_err.out new file mode 100644 index 0000000000..bd73ede16a --- /dev/null +++ b/vlib/v/scanner/tests/oct_consecutively_separator_err.out @@ -0,0 +1,5 @@ +vlib/v/scanner/tests/oct_consecutively_separator_err.vv:2:9: error: separator `_` is only valid between digits in a numeric literal + 1 | fn main() { + 2 | _ := 0o_20 + | ^ + 3 | } diff --git a/vlib/v/scanner/tests/oct_consecutively_separator_err.vv b/vlib/v/scanner/tests/oct_consecutively_separator_err.vv new file mode 100644 index 0000000000..87709cdca1 --- /dev/null +++ b/vlib/v/scanner/tests/oct_consecutively_separator_err.vv @@ -0,0 +1,3 @@ +fn main() { + _ := 0o_20 +} diff --git a/vlib/v/scanner/tests/oct_separator_in_front_err.out b/vlib/v/scanner/tests/oct_separator_in_front_err.out new file mode 100644 index 0000000000..f0458d6114 --- /dev/null +++ b/vlib/v/scanner/tests/oct_separator_in_front_err.out @@ -0,0 +1,5 @@ +vlib/v/scanner/tests/oct_separator_in_front_err.vv:2:9: error: separator `_` is only valid between digits in a numeric literal + 1 | fn main() { + 2 | _ := 0o_20 + | ^ + 3 | } diff --git a/vlib/v/scanner/tests/oct_separator_in_front_err.vv b/vlib/v/scanner/tests/oct_separator_in_front_err.vv new file mode 100644 index 0000000000..87709cdca1 --- /dev/null +++ b/vlib/v/scanner/tests/oct_separator_in_front_err.vv @@ -0,0 +1,3 @@ +fn main() { + _ := 0o_20 +} diff --git a/vlib/v/table/table.v b/vlib/v/table/table.v index 01c616542d..938e78f45d 100644 --- a/vlib/v/table/table.v +++ b/vlib/v/table/table.v @@ -355,8 +355,8 @@ pub fn (mut t Table) register_type_symbol(typ TypeSymbol) int { .placeholder { // override placeholder // println('overriding type placeholder `$typ.name`') - t.types[existing_idx] = { - typ | + t.types[existing_idx] = TypeSymbol{ + ...typ methods: ex_type.methods } return existing_idx @@ -368,8 +368,8 @@ pub fn (mut t Table) register_type_symbol(typ TypeSymbol) int { if existing_idx >= string_type_idx && existing_idx <= map_type_idx { if existing_idx == string_type_idx { // existing_type := t.types[existing_idx] - t.types[existing_idx] = { - typ | + t.types[existing_idx] = TypeSymbol{ + ...typ kind: ex_type.kind } } else { diff --git a/vlib/v/tests/complex_assign_test.v b/vlib/v/tests/complex_assign_test.v index ec866105a9..dd80430468 100644 --- a/vlib/v/tests/complex_assign_test.v +++ b/vlib/v/tests/complex_assign_test.v @@ -84,7 +84,7 @@ fn test_assign_multi_expr() { // test practical complex expressions val3 := Object { name: 'initial', value: 19 } mut q, mut r, mut s := if true { - 1 + 1, 'awe' + 'some', { val3 | name: 'ok' } + 1 + 1, 'awe' + 'some', Object{ ...val3, name: 'ok' } } else { 0, '0', Object {} } @@ -97,7 +97,7 @@ fn test_assign_multi_expr() { q, r, s = if false { 0, '0', Object {} } else { - 5, '55', { val3 | value: 555 } + 5, '55', Object{ ...val3, value: 555 } } assert q == 5 assert r == '55' diff --git a/vlib/v/tests/prod/assoc.prod.v b/vlib/v/tests/prod/assoc.prod.v index a5e54270a9..683342f2a5 100644 --- a/vlib/v/tests/prod/assoc.prod.v +++ b/vlib/v/tests/prod/assoc.prod.v @@ -8,8 +8,8 @@ fn new_st() MyStruct { fn get_st() MyStruct { r := new_st() - return { - r | + return MyStruct{ + ...r s: '6' } } diff --git a/vlib/v/tests/struct_test.v b/vlib/v/tests/struct_test.v index 52db2ccd93..bc3761db3d 100644 --- a/vlib/v/tests/struct_test.v +++ b/vlib/v/tests/struct_test.v @@ -164,8 +164,8 @@ fn test_assoc_with_vars() { def2 := Def{ a: 12 } - merged := { - def2 | + merged := Def{ + ...def2 a: 42 } assert merged.a == 42 @@ -181,7 +181,7 @@ const ( fn test_assoc_with_constants() { println(1) /* - QTODO + TODO: merged := { const_def | a: 42 } assert merged.a == 42 assert merged.b == 7 diff --git a/vlib/v/token/position.v b/vlib/v/token/position.v index 4a896be17d..7f722bef29 100644 --- a/vlib/v/token/position.v +++ b/vlib/v/token/position.v @@ -17,8 +17,8 @@ pub fn (pos Position) str() string { } pub fn (pos Position) extend(end Position) Position { - return { - pos | + return Position{ + ...pos len: end.pos - pos.pos + end.len last_line: end.last_line }