Skip to content

<!-- devin-review-comment {"id": "BUG_pr-review-job-57000e4315c14d928b51448bc1a00cc1_0001", "file_path": "src/cmark/block.mbt", "start_line": 67, "end_line": 67, "side": "RIGHT"} -->#112

Description

@bobzhang

馃敶 Block::normalize returns empty Blocks instead of accumulated results

In Block::normalize, after the loop on lines 58-64 finishes, bs is empty (the loop breaks when bs.pop() returns None). Line 67 then returns Blocks({ v: bs, meta }) which is a Blocks with an empty array, silently discarding all normalized child blocks stored in acc. The analogous Inline::normalize at src/cmark/inline.mbt:111 correctly uses the pattern binding is_ => Inlines({ v: is_, meta }) to capture acc, but the block version uses _ => and references the wrong variable.

Comparison with correct Inline::normalize

Block (buggy, line 65-68):

match acc {
  [b] => b
  _ => Blocks({ v: bs, meta })  // bs is empty!
}

Inline (correct, src/cmark/inline.mbt:109-112):

match acc {
  [i] => i
  is_ => Inlines({ v: is_, meta })  // is_ binds to acc
}

(Refers to line 67)

Open in Devin Review

Was this helpful? React with 馃憤 or 馃憥 to provide feedback.

Originally posted by @devin-ai-integration[bot] in #110 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions