patch 8.2.0403: when 'buftype' is "nofile" there is no overwrite check

Problem:    When 'buftype' is "nofile" there is no overwrite check.
Solution:   Also check for existing file when 'buftype' is set.
            (closes #5807)
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index 3fc0161..fbc6dc1 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -656,7 +656,15 @@
   call setline(1, ['L1'])
   set buftype=nowrite
   call assert_fails('write', 'E382:')
-  close!
+
+  for val in ['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help', 'terminal', 'prompt', 'popup']
+    exe 'set buftype=' .. val
+    call writefile(['something'], 'XBuftype')
+    call assert_fails('write XBuftype', 'E13:', 'with buftype=' .. val)
+  endfor
+
+  call delete('XBuftype')
+  bwipe!
 endfunc
 
 " Test for the 'shellquote' option