Skip to content

feat(core): add zero-width negation expression - #3850

Open
floze-the-genius wants to merge 1 commit into
Automattic:masterfrom
floze-the-genius:fix/not-expression-anchor
Open

feat(core): add zero-width negation expression#3850
floze-the-genius wants to merge 1 commit into
Automattic:masterfrom
floze-the-genius:fix/not-expression-anchor

Conversation

@floze-the-genius

@floze-the-genius floze-the-genius commented Jul 18, 2026

Copy link
Copy Markdown

This patch was produced with assistance from an LLM-based coding agent.

Issues

Fixes #3848.

Description

Add expr::Not, a zero-width assertion that succeeds only when its inner expression does not match at the current cursor. Unlike patterns::Invert, it accepts any Expr, including anchors such as AnchorStart.

This provides the missing building block for rules that should match a phrase everywhere except the beginning of a chunk.

Demo

Not applicable; this is a core expression primitive.

How Has This Been Tested?

  • CARGO_BUILD_JOBS=1 cargo test -p harper-core expr::not -- --nocapture - 2 passed
  • CARGO_BUILD_JOBS=1 cargo clippy -p harper-core --lib -- -D warnings - passed
  • cargo fmt --all -- --check - passed
  • git diff --check - passed

AI Disclosure

  • I am a human and didn't use any AI.
  • I used LLM features of my editor, but not an agent.
  • I used an AI agent interactively.
  • I am an agent or I got an agent to do the work autonomously.

If Your PR Implements or Enhances a Linter

  • I made up the sentences in the unit tests.
  • The sentences in the unit tests were generated by an AI.
  • I'm using examples from the bug report / feature request.
  • I collected real-world sentences for the unit tests.

Checklist

  • I have performed a self-review of my own code
  • I have added tests to cover my changes
  • I have considered splitting this into smaller pull requests.

@hippietrail

Copy link
Copy Markdown
Collaborator

I pasted this code into the branch I was working on when I posted #3848 and it does indeed seem to work. Thank you. I'm requesting a review from somebody much more familiar with this aspect of Harper than I am.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

There seems to be no way for a linter to match when not at the start.

2 participants