{"atom":"regression/regex-var-interpolation","family":"regression","slug":"regex-var-interpolation","header":{"atom":"regression/regex-var-interpolation","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/regex-var-interpolation.raku","counts":{"a":1,"f":0,"d":0,"c":0,"r":0,"n":0},"files":["atoms/regression/regex-var-interpolation.grid"],"records":[["0001","","# Regression (issue #15): a variable interpolated into a regex INSIDE ANGLE\n# BRACKETS is compiled as a REGEX; a bare one matches its text LITERALLY.\n# rakupp quote-escaped both, so `/<$p>/` with $p = \"^bar.?\" matched the empty\n# string and `/<@arr>/` matched a single \"b\" instead of \"barc\".\n#\n#   /<$p>/    → the string is a pattern      /$p/    → the string is literal\n#   /<@arr>/  → each element is a pattern    /@arr/  → literal alternation\n#\n# (NOT asserted: captures inside an interpolated pattern. Rakudo does not\n# expose them as $0 of the OUTER regex; rakupp does. Both match the same text,\n# so this is a numbering difference, tracked separately.)\n# Contract: exit 0 + last line PASS.\nmy @fail;\n\n# the issue's two cases, verbatim\nmy $p = \"^bar.?\";\n@fail.push('<$p> as regex')  unless (\"barc\" ~~ /<$p>/).Str eq 'barc';\nmy @arr = (\"foo\", \"^bar.?\");\n@fail.push('<@arr> as regex') unless (\"barc\" ~~ /<@arr>/).Str eq 'barc';\n\n# the bare forms stay LITERAL — a metacharacter must not gain meaning\nmy $lit = \"a.c\";\n@fail.push('bare $p literal match')  unless (\"a.c\" ~~ /$lit/).Str eq 'a.c';\n@fail.push('bare $p is not a regex') if     \"abc\" ~~ /$lit/;\nmy @la = (\"a.c\", \"x\");\n@fail.push('bare @a literal match')  unless (\"a.c\" ~~ /@la/).Str eq 'a.c';\n@fail.push('bare @a is not a regex') if     \"abc\" ~~ /@la/;\n\n# an interpolated pattern is GROUPED: its alternation cannot swallow what\n# follows, and a quantifier applies to the whole thing\nmy $alt = \"a|b\";\n@fail.push('grouped alternation') unless (\"xb\" ~~ /x<$alt>/).Str eq 'xb';\nmy $ab = \"ab\";\n@fail.push('quantified group')    unless (\"abab\" ~~ /[<$ab>]+/).Str eq 'abab';\n\n# <@arr> keeps the longest-first ordering the bare form has\nmy @lf = (\"b\", \"bc\");\n@fail.push('longest first') unless (\"bcd\" ~~ /<@lf>/).Str eq 'bc';\n\n# a named assertion is still a rule call, not a variable\ngrammar G { token TOP { <w> }; token w { \\w+ } }\n@fail.push('named rule intact') unless G.parse('hi');\n\nif @fail { note \"FAILED:\\n\" ~ @fail.join(\"\\n\"); say 'FAIL' }\nelse     { say 'PASS' }","output PASS","a",["PASS","PASS"],0,[["budget","20s"]]]]}