patch 8.1.1188: not all Vim variables require the v: prefix

Problem:    Not all Vim variables require the v: prefix.
Solution:   When scriptversion is 3 all Vim variables can only be used with
            the v: prefix.  (Ken Takata, closes #4274)
diff --git a/src/eval.c b/src/eval.c
index 5f45d69..dd66287 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -7672,10 +7672,14 @@
 	    return NULL;
 	*varname = name;
 
-	/* "version" is "v:version" in all scopes */
-	hi = hash_find(&compat_hashtab, name);
-	if (!HASHITEM_EMPTY(hi))
-	    return &compat_hashtab;
+	// "version" is "v:version" in all scopes if scriptversion < 3.
+	// Same for a few other variables marked with VV_COMPAT.
+	if (current_sctx.sc_version < 3)
+	{
+	    hi = hash_find(&compat_hashtab, name);
+	    if (!HASHITEM_EMPTY(hi))
+		return &compat_hashtab;
+	}
 
 	ht = get_funccal_local_ht();
 	if (ht == NULL)
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 31caa93..46d6dcb 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -5127,7 +5127,7 @@
     nr = getdigits(&eap->arg);
     if (nr == 0 || *eap->arg != NUL)
 	emsg(_(e_invarg));
-    else if (nr > 2)
+    else if (nr > 3)
 	semsg(_("E999: scriptversion not supported: %d"), nr);
     else
 	current_sctx.sc_version = nr;
diff --git a/src/testdir/test_eval_stuff.vim b/src/testdir/test_eval_stuff.vim
index d6aeb6f..cba66b7 100644
--- a/src/testdir/test_eval_stuff.vim
+++ b/src/testdir/test_eval_stuff.vim
@@ -154,6 +154,22 @@
   endif
 endfunc
 
+scriptversion 3
+func Test_vvar_scriptversion3()
+  call assert_fails('echo version', 'E121:')
+  call assert_false(exists('version'))
+  let version = 1
+  call assert_equal(1, version)
+endfunc
+
+scriptversion 2
+func Test_vvar_scriptversion2()
+  call assert_true(exists('version'))
+  echo version
+  call assert_fails('let version = 1', 'E46:')
+  call assert_equal(v:version, version)
+endfunc
+
 func Test_scriptversion()
   call writefile(['scriptversion 9'], 'Xversionscript')
   call assert_fails('source Xversionscript', 'E999:')
diff --git a/src/version.c b/src/version.c
index f9b53b0..2761458 100644
--- a/src/version.c
+++ b/src/version.c
@@ -772,6 +772,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1188,
+/**/
     1187,
 /**/
     1186,