{"atom":"regression/quoted-literal-backslash","family":"regression","slug":"quoted-literal-backslash","header":{"atom":"regression/quoted-literal-backslash","kind":"whole-program — a minimal repro, not yet reduced to an atom","source":"curated"},"axes":null,"cols":null,"engines":["rakudo-2026.07","rakupp-3.14.0"],"kinds":["ref","pp"],"defFrom":"rakupp:t/regression/quoted-literal-backslash.raku","counts":{"a":1,"f":0,"d":0,"c":0,"r":0,"n":0},"files":["atoms/regression/quoted-literal-backslash.grid"],"records":[["0001","","# Regression: a single-quoted literal inside a regex keeps its backslashes,\n# 2026-08-04. Found taking JSON::Tiny through its own suite, where\n# `<utf16_codepoint>+ % '\\u'` never saw its separator, so each half of a UTF-16\n# surrogate pair was decoded on its own and an astral character came out as\n# replacement bytes. Every expectation was checked against Rakudo.\n\nmy $ok = True;\nsub ck($got, $want, $l) { unless $got eqv $want { say \"FAIL: $l — {$got.raku} vs {$want.raku}\"; $ok = False } }\n\nmy $bs-n = 'a' ~ '\\\\' ~ 'n' ~ 'b';    # a, backslash, n, b\nmy $nl   = \"a\\nb\";                     # a, newline, b\n\n# Single quotes: the ONLY escapes are \\\\ and \\' — `'\\n'` is backslash-then-n.\nck(?($bs-n ~~ / 'a' '\\n' 'b' /), True,  \"'\\\\n' matches a literal backslash-n\");\nck(?($nl   ~~ / 'a' '\\n' 'b' /), False, \"…and NOT a newline\");\nck(?('a\\\\b' ~~ / 'a' '\\\\' 'b' /), True, \"'\\\\\\\\' is one backslash\");\nck(?(\"a'b\"  ~~ / 'a' '\\'' 'b' /), True, \"'\\\\'' is a quote\");\n\n# Double quotes keep the usual escapes.\nck(?($nl   ~~ / 'a' \"\\n\" 'b' /), True,  '\"\\\\n\" is a real newline');\nck(?($bs-n ~~ / 'a' \"\\n\" 'b' /), False, '…and not a backslash-n');\n\n# The shape that found it: a separated quantifier whose separator is `'\\u'`.\n{\n    grammar G {\n        token TOP { 'u' <hex>+ % '\\u' }\n        token hex { <xdigit> ** 4 }\n    }\n    my $m = G.parse('uD835\\uDCB7');\n    ck(?$m, True, 'the separator matches inside a grammar token');\n    ck(($m ?? $m<hex>.elems !! 0), 2, 'and both halves land in ONE match');\n    # …which is what lets the pair decode as one astral codepoint\n    ck(utf16.new(0xD835, 0xDCB7).decode().ords.List, (119991,), 'the surrogate pair decodes');\n}\n\nsay $ok ?? 'PASS' !! 'FAIL';","output PASS","a",["PASS","PASS"],0,[["budget","20s"]]]]}