Skip to content

Conversation

@timotheecour
Copy link
Member

@timotheecour timotheecour commented Feb 29, 2020

caveat

Here's an edge case that could be considered a false positive depending on how you interpret --word, but it's a bit trickier o fix and definitely better than having false negatives

/Users/timothee/git_clone/nim/Nim_prs/tools/nimgrep --find -r --ext:nim --word '\$\$' lib
lib/pure/parseutils.nim:588:     for k, v in interpolatedFragments("  $this is ${an  example}  $$"):
lib/pure/marshal.nim:45: ## **Note**: The ``to`` and ``$$`` operations are available at compile-time!
lib/pure/marshal.nim:296: proc `$$`*[T](x: T): string =
lib/pure/strutils.nim:2709:   ## To produce a verbatim ``$``, use ``$$``.
lib/pure/strscans.nim:41: ``$$``              Matches a single dollar sign.
lib/pure/strscans.nim:693:   let xx = scanf("$abc", "$$$i", intval)
lib/pure/strscans.nim:697:   let xx2 = scanf("$1234", "$$$i", intval)
lib/pure/parsexml.nim:609:   # if we have no name, we have '<tag attr= key %&$$%':
lib/impure/nre.nim:713:   ## -  ``$$`` - literal ``$``
9 matches

ripgrep has same issue here:

echo 'let xx = scanf("$abc", "$$$i", intval)' | rg -w '\$\$'
let xx = scanf("$abc", "$$$i", intval)

TODO for future PR

  • --word should add an extra check that filters out entries bcd preceded by a b or succeeded by a d; this would filter out $$$i in this case.
  • ripgrep could use a similar trick /cc @BurntSushi

@timotheecour timotheecour force-pushed the pr_fix_13528_nimgrep_word branch from 169b545 to 8f2bc71 Compare March 2, 2020 11:08
@Araq Araq merged commit 27241fd into nim-lang:devel Mar 2, 2020
@timotheecour timotheecour deleted the pr_fix_13528_nimgrep_word branch March 2, 2020 23:10
@timotheecour timotheecour changed the title fix #13528 nimgrep --word now works with operators [TODO] fix #13528 nimgrep --word now works with operators Mar 2, 2020
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.

[minor] nimgrep --word doesn't work with operators (eg misses 1 +% 2)

2 participants