fix: handle multi-line function signatures in contract extraction#939
Merged
fix: handle multi-line function signatures in contract extraction#939
Conversation
Two extraction gaps that caused wrong test generation:
1. Multi-line params: when a function signature spans multiple lines,
the grammar's per-line regex only captures the first line's params.
Now join_declaration_lines() concatenates from fn through { to get
the full text, and extract_params_from_declaration() re-parses the
complete param list with balanced-paren tracking.
2. Multi-line return types: detect_return_shape() only read the fn line.
When the return type is on a continuation line (common with long
signatures), it saw Unit instead of Result/Option. Now it reads
the full joined declaration.
Both fixes use the same join: raw_lines[fn_line..body_start].
9 unit tests added for join_declaration_lines and
extract_params_from_declaration.
Contributor
Homeboy Results —
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two extraction gaps that caused wrong test generation for functions with multi-line signatures (#818).
Problem
The contract extractor operated per-line:
detect_return_shapeonly read thefnline → return type on a continuation line was invisible (Unitinstead ofResult)Fix
join_declaration_lines()— concatenates raw lines fromfnthrough{into a single stringextract_params_from_declaration()— re-parses the full param list with balanced-paren tracking (handlesHashMap<String, Vec<u8>>correctly)detect_return_shapenow receives the joined declaration, so return types on continuation lines are foundis_asyncdetection also uses the full declarationTests
9 unit tests covering: