rouge icon indicating copy to clipboard operation
rouge copied to clipboard

nix: Fix identifier lexing

Open nsfisis opened this issue 1 month ago • 0 comments

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 avatar Nov 15 '25 17:11 nsfisis