{"atom":"regression/topic-alias-and-repl-methods","family":"regression","slug":"topic-alias-and-repl-methods","header":{"atom":"regression/topic-alias-and-repl-methods","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/topic-alias-and-repl-methods.raku","counts":{"a":1,"f":0,"d":0,"c":0,"r":0,"n":0},"files":["atoms/regression/topic-alias-and-repl-methods.grid"],"records":[["0001","","# Regression: two fixes found taking HTTP::Tiny from 7 to 8 of its 10 files,\n# 2026-08-04. Both are general; the module only showed where to look. Every\n# expectation 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\n# 1. `$_` is an ALIAS to the topic, not a copy, so a mutation writes back to the\n#    variable. Array topics already did this (their elements are containers);\n#    a SCALAR topic did not, so `s/x/y/ given $str` quietly changed nothing.\n{\n    my $a = 'foo';  s/f/F/ given $a;            ck($a, 'Foo', 'given as a statement modifier');\n    my $b = 'foo';  given $b { s/f/F/ }         ; ck($b, 'Foo', 'given as a block');\n    my $c = 'foo';  given $c { $_ = .uc }       ; ck($c, 'FOO', 'assigning to $_ writes back');\n    my $d = 'foo';  for $d { s/f/F/ }           ; ck($d, 'Foo', 'a scalar `for` topic too');\n\n    my @e = <foo bar>; for @e { s/o/0/ };         ck(@e, ['f0o', 'bar'], 'an array topic is unchanged');\n\n    # a topic with nowhere to write back is left alone rather than erroring\n    my $lit = do given 'literal' { $_.uc };\n    ck($lit, 'LITERAL', 'a literal topic still works');\n    my $f = 'keep';\n    my $viaCall = do given $f.uc { $_ };\n    ck($viaCall, 'KEEP', 'a call result is not written back');\n    ck($f, 'keep', 'and the source is untouched');\n}\n\n# 2. `$0.uc()` in a substitution replacement is a METHOD CALL, as in any other\n#    interpolating string — and, as there, only WITH parentheses.\n{\n    my $a = 'content-type';\n    $a ~~ s:g/ <|w> (\\w) /$0.uc()/;\n    ck($a, 'Content-Type', 'a method call on a capture');\n\n    my $b = 'hello world';\n    $b ~~ s:g/(\\w+)/$0.tc()/;\n    ck($b, 'Hello World', 'and on each match of a global substitution');\n\n    my $c = 'xy';\n    $c ~~ s/(x)/[$0]/;\n    ck($c, '[x]y', 'a plain capture is unaffected');\n\n    my $d = 'content-type';\n    $d ~~ s:g/ <|w> (\\w) /{$0.uc}/;\n    ck($d, 'Content-Type', 'the block form still works');\n}\n\nsay $ok ?? 'PASS' !! 'FAIL';","output PASS","a",["PASS","PASS"],0,[["budget","20s"]]]]}