Skip to content

fix(scanner): end type annotation at function body brace#4

Merged
DylanPiercey merged 1 commit into
mainfrom
claude/htmljs-parser-tree-sitter-fixes-dm8wj0
Jun 26, 2026
Merged

fix(scanner): end type annotation at function body brace#4
DylanPiercey merged 1 commit into
mainfrom
claude/htmljs-parser-tree-sitter-fixes-dm8wj0

Conversation

@DylanPiercey

@DylanPiercey DylanPiercey commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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.

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.
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

In src/scanner.c, the { branch in scan_expr_inner now checks for a preceding operator when the scanner is in type mode and not force-type. It walks back over whitespace, calls look_behind_for_operator, and clears e->in_type when no applicable operator is found.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the scanner change that ends type annotation handling at a function body brace.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description matches the scanner change and explains the new { handling in type mode.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/htmljs-parser-tree-sitter-fixes-dm8wj0

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 90c94d70-743b-4cf5-be0c-98efbc797c44

📥 Commits

Reviewing files that changed from the base of the PR and between 1389646 and 2c28259.

📒 Files selected for processing (1)
  • src/scanner.c

Comment thread src/scanner.c
@DylanPiercey
DylanPiercey merged commit 37721c2 into main Jun 26, 2026
8 checks passed
@DylanPiercey
DylanPiercey deleted the claude/htmljs-parser-tree-sitter-fixes-dm8wj0 branch June 26, 2026 03:49
@DylanPiercey DylanPiercey moved this to Done in Roadmap Jun 29, 2026
@DylanPiercey DylanPiercey self-assigned this Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant