updated for version 7.4.149
Problem:    Get E685 error when assigning a function to an autoload variable.
            (Yukihiro Nakadaira)
Solution:   Instead of having a global no_autoload variable, pass an autoload
            flag down to where it is used. (ZyX)
diff --git a/src/testdir/sautest/autoload/footest.vim b/src/testdir/sautest/autoload/footest.vim
new file mode 100644
index 0000000..f467bc3
--- /dev/null
+++ b/src/testdir/sautest/autoload/footest.vim
@@ -0,0 +1,5 @@
+" Autoload script used by test55 and test60
+let footest#x = 1
+func footest#F()
+  return 0
+endfunc
diff --git a/src/testdir/test55.in b/src/testdir/test55.in
index 991c460..4b20de4 100644
--- a/src/testdir/test55.in
+++ b/src/testdir/test55.in
Binary files differ
diff --git a/src/testdir/test55.ok b/src/testdir/test55.ok
index 7375007..396c9be 100644
--- a/src/testdir/test55.ok
+++ b/src/testdir/test55.ok
@@ -86,6 +86,9 @@
 FFpFFpp
 0000-000
 ppppppp
+locked g:footest#x:-1
+exists g:footest#x:0
+g:footest#x: 1
 caught a:000
 caught a:000[0]
 caught a:000[2]
diff --git a/src/testdir/test60.in b/src/testdir/test60.in
index 3a5b73e..0f30142 100644
--- a/src/testdir/test60.in
+++ b/src/testdir/test60.in
@@ -1,4 +1,4 @@
-Tests for the exists() function.  vim: set ft=vim :
+Tests for the exists() function.  vim: set ft=vim ts=8 :
 
 STARTTEST
 :so small.vim
@@ -11,8 +11,10 @@
 endfunction
 :function! TestExists()
     augroup myagroup
-	autocmd! BufEnter *.my echo 'myfile edited'
+	autocmd! BufEnter       *.my     echo "myfile edited"
+	autocmd! FuncUndefined  UndefFun exec "fu UndefFun()\nendfu"
     augroup END
+    set rtp+=./sautest
 
     let test_cases = []
 
@@ -95,10 +97,15 @@
     " Non-existing user defined function
     let test_cases += [['*MyxyzFunc', 0]]
 
+    " Function that may be created by FuncUndefined event
+    let test_cases += [['*UndefFun', 0]]
+    " Function that may be created by script autoloading
+    let test_cases += [['*footest#F', 0]]
+
     redir! > test.out
 
     for [test_case, result] in test_cases
-      	echo test_case . ": " . result
+        echo test_case . ": " . result
         call RunTest(test_case, result)
     endfor
 
@@ -207,6 +214,14 @@
 	echo "FAILED"
     endif
 
+    " Non-existing autoload variable that may be autoloaded
+    echo 'footest#x: 0'
+    if !exists('footest#x')
+	echo "OK"
+    else
+	echo "FAILED"
+    endif
+
     " Valid local list
     let local_list = ["blue", "orange"]
     echo 'local_list: 1'
@@ -566,6 +581,10 @@
 
     call TestFuncArg("arg1", "arg2")
 
+    echo ' g:footest#x =' g:footest#x
+    echo '   footest#F()' footest#F()
+    echo 'UndefFun()' UndefFun()
+
     redir END
 endfunction
 :call TestExists()
@@ -576,5 +595,6 @@
 :set ff=unix
 :w
 :qa!
+:while getchar(1) | call getchar() | endwhile
 ENDTEST
 
diff --git a/src/testdir/test60.ok b/src/testdir/test60.ok
index 10dc579..0c382ad 100644
--- a/src/testdir/test60.ok
+++ b/src/testdir/test60.ok
@@ -71,6 +71,10 @@
 OK
 *MyxyzFunc: 0
 OK
+*UndefFun: 0
+OK
+*footest#F: 0
+OK
 :edit: 2
 OK
 :edit/a: 0
@@ -95,6 +99,8 @@
 OK
 local_var: 0
 OK
+footest#x: 0
+OK
 local_list: 1
 OK
 local_list[1]: 1
@@ -195,3 +201,6 @@
 OK
 a:2: 0
 OK
+ g:footest#x = 1
+   footest#F() 0
+UndefFun() 0