diff --git a/doc_src/cmds/function.rst b/doc_src/cmds/function.rst index 445965da9..1e2c2feef 100644 --- a/doc_src/cmds/function.rst +++ b/doc_src/cmds/function.rst @@ -68,6 +68,8 @@ By using one of the event handler switches, a function can be made to run automa - ``fish_cancel``, which is emitted when a commandline is cleared (used for terminal-shell integration). +Functions may not be named the same as a reserved keyword. These are elements of fish syntax or builtin commands which are essential for the operations of the shell. Current reserved words are ``[``, ``_``, ``and``, ``argparse``, ``begin``, ``break``, ``builtin``, ``case``, ``command``, ``continue``, ``else``, ``end``, ``eval``, ``exec``, ``for``, ``function``, ``if``, ``not``, ``or``, ``read``, ``return``, ``set``, ``status``, ``string``, ``switch``, ``test``, ``time``, and ``while``. + Example ------- diff --git a/src/parser_keywords.cpp b/src/parser_keywords.cpp index e3253d2de..c7ae27b46 100644 --- a/src/parser_keywords.cpp +++ b/src/parser_keywords.cpp @@ -22,6 +22,7 @@ static const wcstring subcommand_keywords[]{L"command", L"builtin", L"while", L" static const string_set_t block_keywords = {L"for", L"while", L"if", L"function", L"switch", L"begin"}; +// Don't forget to add any new reserved keywords to the documentation static const wcstring reserved_keywords[] = { L"end", L"case", L"else", L"return", L"continue", L"break", L"argparse", L"read", L"string", L"set", L"status", L"test", L"[", L"_", L"eval"};