Skip to content

Perl: a ternary counts twice, and regex-literal and string text count toward branch, bitwise_ops and decorators #8908

Done

Description

@squid-protocol

What is wrong

Perl branch (and, from the same tokens, decorators and bitwise_ops) fires on ordinary Perl that has no decision. Found with a Perl oracle on bugzilla (2,633 functions matched; args 1.00 / 1.00 and branch recall 1.00, so the oracle reads functions correctly; branch precision 0.96):

Reproduce (pinned scanner; counts read from function_data; columns struct_branch / bitwise_ops / struct_decorators)

sub tern { my $a = shift; return $a ? 1 : 2; }                # branch 2, should be 1
sub rx   { my $s = shift; return $s =~ /^(?:a|b)$/; }         # branch 2, bitwise 1, decorators 1; should be 0, 0, 0
sub dsn  { return "dbi:mysql:host"; }                         # branch 2, decorators 2 (strings: #2535)
sub real_if { my $a = shift; if ($a) { return 1 } return 0 }  # branch 1, correct

Expected

Count the ternary once at its ?, anchored on operator position; do not read the contents of a regex literal (m//, s///, qr//) as code for branch, bitwise_ops and decorators.

Part of #8863. Time the change; rosetta:rebless-owed if counts move; add each case as a test.

Activity

  1. added
    bug
    core-engine
    on Nov 21, 2026
  2. squid-protocol commented on Nov 23, 2026

    @squid-protocol
    OwnerAuthor

    This issue's PR content landed via #9111 (merged as fcc440b). It was a 'Part of' change, so the issue stays open for the remaining work.

  3. squid-protocol commented on Nov 24, 2026

    @squid-protocol
    OwnerAuthor

    Claimed by promoter-bot host melek, lease renewed 2026-11-24T12:53Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove the claim:melek label.

  4. squid-protocol commented on Nov 24, 2026

    @squid-protocol
    OwnerAuthor

    Closing: the fix landed in #9111 (ternary counted once at its ?, regex-literal (?:...) text no longer counts toward branch/bitwise_ops/decorators); tests/extraction/languages/test_perl_branch_literals_8908.py pins all four repros (17 pass). Note: the string-colon case also scores (0,0,0) now, differing from the issue's Expected text.

  5. squid-protocol commented on Nov 24, 2026

    @squid-protocol
    OwnerAuthor

    Churn run 8908-20261124T1310Z (host melek) ended without a PR. fix already on main via #9111; issue closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclaim:melekcore-enginepriority: medium

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions