fix(#6028): capture the full Solidity declaration signature, not just the name - #6029
Conversation
functionRE, eventRE and modifierRE end at the opening paren, and the
extractor recorded the regex match span as Signature. Every Solidity
function, event and modifier therefore carried a signature truncated at
that paren, such as "function transfer(". Measured across seven
production Solidity repositories: 5255 declarations with a signature,
5255 truncated, none complete.
declSignature scans on from the match with paren depth and stops at the
first { or ; at depth zero, which takes in the parameter list and a
returns (...) clause in one pass. It does not repeat the comment and
string handling in extractBracedBody: findContracts is fed
stripCommentsAndStrings output, so a delimiter written inside a comment
or a literal is already blank and cannot end a signature early. A
declaration with no terminator falls back to the previous span, so
truncated source degrades to today's behaviour rather than running to
the end of the contract.
On the same seven repositories the change affects one field and nothing
else: entity ids are unchanged, no entity differs in any field other
than signature, and all 745 cross-repository edges derived from the
graph are identical.
The capability entry was added before the issue existed, so issues_implemented was empty.
|
Thank you for this — it's a genuinely nice piece of work, and a few things stand out. The diagnosis is exact. "The regexes end at the opening paren" is the whole bug in one line, and noting that
Two judgement calls I particularly appreciated: You documented the limitation instead of hiding it. The fallback degrades instead of running away. A declaration with no terminator returning the previous span means malformed source gets the old behaviour rather than swallowing the rest of the contract. That's the conservative choice and it's the right one. The before/after across seven production repositories — 5255 truncated to 0, entity ids unchanged, no field other than And thank you for updating Merging as-is. Nothing needed from you. |
declSignaturescans forward from the declaration regex match with paren depth and stops at the first{or;at depth zero, so the parameter list and anyreturns (...)clause are captured. The extractor previously stored the regex match span itself, which ends at the opening paren.extractBracedBody.findContractsis fedstripCommentsAndStringsoutput, so a{or;inside a comment or a literal cannot end a signature early.onlyRole("ADMIN)ROLE")is captured asonlyRole( ). The third test pins that rather than leaving it to be found in review.Tests cover the multi-line, nested-paren and
;-terminated interface shapes, events, modifiers, and the comment/string case. Each fails against v0.1.9.go test ./...green (224 packages),go vetandgofmt -l internal/extractors/solidityclean, andtools/coverage validate,backfill --checkandfmt --checkexit 0 withgenleavingdocs/coveragebyte-identical. Coverage matrix updated per AGENTS.md.Closes #6028