fix(scanner): end type annotation at function body brace#4
Merged
Merged
Conversation
Port htmljs-parser's statement-function return type fix to the external
scanner. A `{` following a completed type now ends the type annotation so
a `>` in the function body is no longer parsed as a closing generic
bracket. If the preceding non-whitespace is an operator/continuation the
`{` is treated as part of the type (eg an object return type) and type
mode stays on.
Mirrors marko-js/htmljs-parser#224.
WalkthroughIn 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/scanner.c`:
- Around line 1020-1025: Mirror the existing should_terminate guard in the
brace-handling logic inside scanner.c so resumed split types are not cleared too
early. In the branch that checks e->in_type and !e->force_type, add the same
can_look / resume_lookbehind condition before calling
look_behind_for_operator(), since cfg_tag_var() sets resume_lookbehind and
leaves force_type false; keep e->in_type true when lookbehind is not safe, and
only clear it when the operator check is valid for the current token state.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
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.
Ports the scanner fix from marko-js/htmljs-parser#224 to the external scanner.
A
{following a completed type now ends the return type annotation, so a>in a statement function's body is no longer parsed as a closing generic bracket.