Skip to content

Cleanup and bugfixes: remove dead IR, fix lexer and args parsing#9

Open
arismoko wants to merge 4 commits into
mainfrom
pip/cleanup-and-bugfixes
Open

Cleanup and bugfixes: remove dead IR, fix lexer and args parsing#9
arismoko wants to merge 4 commits into
mainfrom
pip/cleanup-and-bugfixes

Conversation

@arismoko

Copy link
Copy Markdown
Owner

Summary

This PR addresses P0 and P1 issues found during codebase review:

P0 (Dead Code)

  • Remove dead inline IR types: Deleted Bold, Italic, Underline, Strikethrough, Highlight, Code, Link, Image from IR and emitter. These were defined and had emission code but no producer in the evaluator.
  • Remove dead HorizontalRule: Same issue — defined but never produced.

P1 (Spec Violations / Correctness Bugs)

  • Fix comment lexing in paragraphs: Per spec §3.2, // inside paragraph blocks [...] should be literal text, not a comment. The lexer was incorrectly producing COMMENT tokens inside paragraphs.
  • Fix number parsing validation: Args parser accepted invalid patterns like 1-2 which parseFloat silently truncated to 1. Now properly validates and emits diagnostics for malformed numbers.

Spec Cleanup

  • Remove @if/@for from deferred section: Control flow directives are deferred indefinitely per discussion — removed from spec to avoid tracking features that won't be implemented.

Test plan

  • All 208 existing tests pass
  • Manual verification of dead code removal (no references to removed types)
  • Comment lexing fix aligns with spec §3.2
  • Number parsing now rejects 1-2, 1..2, -+1 patterns

🤖 Managed by Pip (Ari's AI assistant)

…ontalRule

Remove unused IR types that were never produced by the parser:
- Inline: Bold, Italic, Underline, Strikethrough, Highlight, Code, Link, Image
- Block: HorizontalRule

Also remove corresponding emission code in nodes.ts and update
inline-text.ts walker to only handle Styled wrapper nodes.
Add paragraphDepth tracking to lexer. Only recognize // as a comment
when outside paragraph blocks [...]. Inside [...], // is literal text.
parseFloat silently truncates at first invalid character, so '1-2'
would parse as 1 without error. Added regex validation to ensure
the scanned string is a valid JSON5 number format before accepting it.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7e26445f12

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/parse/lexer.ts
// Line comment
if (char === "/" && this.peek(1) === "/") {
// Line comment (only outside paragraph context - Spec §3.2)
if (char === "/" && this.peek(1) === "/" && this.paragraphDepth === 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Decouple line-comment lexing from bracket depth

Restricting // comments to paragraphDepth === 0 causes recovery regressions after malformed args that contain an unmatched [ (e.g. @d(a:[1,2)\n// note\n@x): the lexer never returns to depth 0, so subsequent structural comments are tokenized as plain text instead of COMMENT, producing cascaded UNEXPECTED_TOKEN warnings and violating the spec’s structural-comment and recovery guarantees (§3.2, §17.2/§17.3).

Useful? React with 👍 / 👎.

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.

1 participant