mirror of
https://github.com/NixOS/nix
synced 2025-06-28 22:01:15 +02:00
libexpr: quote reserved keys when printing
This fixes a bug in commands like `nix eval' which would emit invalid attribute sets if they contained reserved keywords such as "assert", "let", etc. These keywords will not be quoted when printed, making them valid expressions. All keywords recognized by the lexer are quoted except "or", which does not require quotation.
This commit is contained in:
parent
4539ab530a
commit
b72bc4a972
4 changed files with 33 additions and 4 deletions
|
@ -35,6 +35,12 @@ namespace nix {
|
|||
*/
|
||||
std::ostream & printAttributeName(std::ostream & o, std::string_view s);
|
||||
|
||||
/**
|
||||
* Returns `true' is a string is a reserved keyword which requires quotation
|
||||
* when printing attribute set field names.
|
||||
*/
|
||||
bool isReservedKeyword(const std::string_view str);
|
||||
|
||||
/**
|
||||
* Print a string as an identifier in the Nix expression language syntax.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue