From 2ac579ca0afaf1018476cb7cceb43e9f9b58a553 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 25 Jul 2019 14:13:35 +0200 Subject: [PATCH] wrap up the new mut check --- CHANGELOG.md | 1 + examples/tetris/tetris.v | 2 +- vlib/builtin/array_test.v | 2 +- vlib/builtin/string_test.v | 2 +- vlib/math/stats_test.v | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8e6e18367..a53b0c3cfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - @ for escaping keywords (e.g. `struct Foo { @type string }`). - Windows Unicode fixes (V can now work with non-ASCII paths etc on Windows). - Fix mutable args bugs + don't allow primitive arguments to be modified. +- Declaring a mutable variable and never modifying it results in a compilation error. ## V 0.1.16 diff --git a/examples/tetris/tetris.v b/examples/tetris/tetris.v index f0f0a5484c..7a6e634d44 100644 --- a/examples/tetris/tetris.v +++ b/examples/tetris/tetris.v @@ -226,7 +226,7 @@ fn (g mut Game) delete_completed_line(y int) { for yy := y - 1; yy >= 1; yy-- { for x := 1; x <= FieldWidth; x++ { mut a := g.field[yy + 1] - mut b := g.field[yy] + b := g.field[yy] a[x] = b[x] } } diff --git a/vlib/builtin/array_test.v b/vlib/builtin/array_test.v index 83c4b87415..efa9a6c77f 100644 --- a/vlib/builtin/array_test.v +++ b/vlib/builtin/array_test.v @@ -109,7 +109,7 @@ fn test_repeat() { assert aa[9] == f32(1.1) } { - mut aa := [f64(1.1) ; 10] + aa := [f64(1.1) ; 10] assert aa[0] == f64(1.1) assert aa[5] == f64(1.1) assert aa[9] == f64(1.1) diff --git a/vlib/builtin/string_test.v b/vlib/builtin/string_test.v index d0e6eb1155..6a91d693e9 100644 --- a/vlib/builtin/string_test.v +++ b/vlib/builtin/string_test.v @@ -141,7 +141,7 @@ fn test_clone() { a += 'a' a += 'a' b := a - mut c := a.clone() + c := a.clone() assert c == a assert c == 'aaa' assert b == 'aaa' diff --git a/vlib/math/stats_test.v b/vlib/math/stats_test.v index 09aab5c2d2..368930a54f 100644 --- a/vlib/math/stats_test.v +++ b/vlib/math/stats_test.v @@ -256,4 +256,5 @@ fn test_passing_empty() { assert stats.min(data) == f64(0) assert stats.max(data) == f64(0) assert stats.range(data) == f64(0) +}