Skip to content

swift: api rule matches bare 'open' anywhere, including inside string literals #2544

Closed

Description

@squid-protocol

Summary

Found by the #1096 control corpus: swift's api rule matches the bare word open anywhere — including inside string literals and any identifier/prose use — not just as an access modifier position.

Evidence

data/swift/b.swift plants zero api keywords; the string decoy let note = "if eval fails, try open" records api = 1. finditer on the api rule returns ['open'] from inside the literal.

Impact

Any swift file whose strings, comments-adjacent code, or function names contain open (e.g. openFile, wait — boundary-guarded, but bare open(...) calls and prose in literals) gains API-exposure mass. open is a common verb; as an access modifier it only means anything pre-declaration.

Fix shape

Anchor open to declaration position (^[ \t]*open[ \t]+(?:class|func|var|...)) like the other modifiers presumably are, and/or rely on literal shielding once #2535 is settled.

References

#1096 corpus ledger + #2535 (literal-surface counting is the enabling half of this FP).

Activity

  1. added
    core-engine
    on Aug 31, 2026
  2. squid-protocol commented on Sep 4, 2026

    @squid-protocol
    OwnerAuthor

    Shipped in #2677 (B.3 wave 1 of #2669): swift's api rule now steps bounded modifiers instead of matching bare open anywhere; strict tests in tests/extraction/languages/test_swift_strict.py. Stayed open because #2677's Closes was a comma-list, which GitHub parses only for the first reference. Closing as done.

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

    core-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions