Skip to content

fix(jsx): support {#* block comments *#} inside JSX body#5587

Open
Developer-Linus wants to merge 15 commits intojaseci-labs:mainfrom
Developer-Linus:JSX/client_components
Open

fix(jsx): support {#* block comments *#} inside JSX body#5587
Developer-Linus wants to merge 15 commits intojaseci-labs:mainfrom
Developer-Linus:JSX/client_components

Conversation

@Developer-Linus
Copy link
Copy Markdown
Collaborator

Parser

Added a guard in parse_jsx_child so that when a { } brace pair contains only a comment (which the lexer already consumed), the parser detects the immediately-following } and recurses rather than attempting to parse a missing expression — fixing the parse error.

Grammar spec (jac.spec) updated to reflect the new jsx_child production rule.


Formatter

Fixed a bug in CommentInjectionPass where {#* ... *#} in a JSX body was displaced to end-of-file.

Root cause: the parser consumes the bare { } tokens without attaching them to any AST node, so the comment's anchor hash is never found in the doc tree.

Fix: detects this pattern (LBRACE anchor immediately followed by RBRACE) and reclassifies the comment as standalone with an is_jsx_body flag, so it is re-emitted wrapped in { ... } at the correct line position between JSX children.

Tests

Added parser and formatter tests covering the {#* comment *#} case, including a sibling-displacement regression test.

Fixture file jsx_body_comment.jac added.

Docs

Documented the {#* ... *#} JSX body comment syntax in the quick-guide cheatsheet and the internals design doc.

Developer-Linus and others added 13 commits April 16, 2026 13:22
Add fixture and tests for the {#* ... *#} parser fix, ensuring correct
handling of comment-only braces in JSX children.

Covers three scenarios:

* comment between sibling elements
* comment as the sole child
* comment adjacent to a real {expr}

These cases verify the parser no longer misinterprets or drops
comment-only brace blocks within JSX bodies.
Add four failing tests for the comment injection pass regression where
{#* block comment *#} inside a JSX body is displaced to the end of file
(E5051) instead of being preserved in place.

Root cause:
The comment is classified as inline (anchored to the LBRACE token), but
the parser consumes and drops that LBRACE without attaching it to any
AST node, so the anchor is never found in the doc tree.

Tests cover:

* comment between siblings - must remain between them in output
* comment as the only child - parent element must not be lost
* comment adjacent to a real {expr} - both must survive in order
* no E5051 displaced-comment error is raised
…aseci-labs#5587)

  Replace shared release-notes entry with unreleased/jaclang/5587.bugfix.md
  following the new per-PR fragment convention.
Comment thread docs/docs/community/release_notes/jaclang.md Outdated
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.

Bug: Component comments are not stripped during render.

2 participants