Skip to main content

is_parser_keyword

Function is_parser_keyword 

Source
pub fn is_parser_keyword(name: &[u8]) -> bool
Expand description

Returns true if name matches any parser keyword (aliasable or unaliasable).

Used to prevent custom commands and aliases from shadowing language keywords (e.g. def def [] {}), which can break subsequent parsing and previously panicked in the REPL. This applies everywhere, including module exports — use mod * would otherwise bring a bare keyword-named command into scope.

Also used when a module is named after a keyword and exports main: invoking that entry point would use the module name as a bare command, which the parser intercepts before command lookup.

Multi-word keywords such as export def and overlay use are included in the lists; they will not match normal single-token definition or module names. See single_word_parser_keywords.