Diff
1diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh
2index afc33829b01c0a09dc0633a21fbfee906c5d3116..9c9905e4d34e0a7b05b9f7905eb9ee238a7b13e5 100644
3--- a/lib/diagnostics.zsh
4+++ b/lib/diagnostics.zsh
5@@ -52,6 +52,9 @@
6 # * Consider whether to move default output file location to TMPDIR. More robust
7 # but less user friendly.
8 #
9+
10+autoload -Uz is-at-least
11+
12 function omz_diagnostic_dump() {
13 emulate -L zsh
14
15@@ -247,7 +250,7 @@ function _omz_diag_dump_one_big_text() {
16
17 function _omz_diag_dump_check_core_commands() {
18 builtin echo "Core command check:"
19- local redefined name builtins externals
20+ local redefined name builtins externals reserved_words
21 redefined=()
22 # All the zsh non-module builtin commands
23 # These are taken from the zsh reference manual for 5.0.2
24@@ -255,17 +258,32 @@ function _omz_diag_dump_check_core_commands() {
25 # (For back-compatibility, if any of these are newish, they should be removed,
26 # or at least made conditional on the version of the current running zsh.)
27 # "history" is also excluded because OMZ is known to redefine that
28+ reserved_words=( do done esac then elif else fi for case if while function
29+ repeat time until select coproc nocorrect foreach end '!' '[[' '{' '}'
30+ )
31 builtins=( alias autoload bg bindkey break builtin bye cd chdir command
32 comparguments compcall compctl compdescribe compfiles compgroups compquote comptags
33- comptry compvalues continue declare dirs disable disown echo echotc echoti emulate
34- enable eval exec exit export false fc fg float functions getln getopts hash
35- integer jobs kill let limit local log logout noglob popd print printf
36- pushd pushln pwd r read readonly rehash return sched set setopt shift
37- source suspend test times trap true ttyctl type typeset ulimit umask unalias
38+ comptry compvalues continue dirs disable disown echo echotc echoti emulate
39+ enable eval exec exit false fc fg functions getln getopts hash
40+ jobs kill let limit log logout noglob popd print printf
41+ pushd pushln pwd r read rehash return sched set setopt shift
42+ source suspend test times trap true ttyctl type ulimit umask unalias
43 unfunction unhash unlimit unset unsetopt vared wait whence where which zcompile
44 zle zmodload zparseopts zregexparse zstyle )
45+ if is-at-least 5.1; then
46+ reserved_word+=( declare export integer float local readonly typeset )
47+ else
48+ builtins+=( declare export integer float local readonly typeset )
49+ fi
50 builtins_fatal=( builtin command local )
51 externals=( zsh )
52+ for name in $reserved_words; do
53+ if [[ $(builtin whence -w $name) != "$name: reserved" ]]; then
54+ builtin echo "reserved word '$name' has been redefined"
55+ builtin which $name
56+ redefined+=$name
57+ fi
58+ done
59 for name in $builtins; do
60 if [[ $(builtin whence -w $name) != "$name: builtin" ]]; then
61 builtin echo "builtin '$name' has been redefined"