Skip to content

Conversation

@nsfisis
Copy link
Contributor

@nsfisis nsfisis commented Nov 15, 2025

Fix #2176

Nix identifiers can contain ' and -, which are not "word" characters in Ruby regexp. Thus, the pattern /if\b/ (literal "if" followed by a word boundary) will match with if within if'.

This pull request defines id_boundary pattern as /(?![a-zA-Z_0-9'-])/, "not followed by Nix identifier characters" and replaces \b with it.

Nix manual:
https://nix.dev/manual/nix/2.28/language/identifiers.html

Syntax

identifier ~ [A-Za-z_][A-Za-z0-9_'-]*

@nsfisis nsfisis force-pushed the nix/fix-ident-lexing branch from f82436b to 9ba25b9 Compare November 15, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nix: variables starting with reserved keywords are highlighted incorrectly

1 participant