Skip to content

[Bug]: any markdown link crashes the macOS renderer (empty array stored as underlineStyle) #128

Description

Summary

any markdown link crashes the macOS/AppKit renderer with NSInvalidArgumentException: -[Swift.__EmptyArrayStorage integerValue]: unrecognized selector. root cause: Markdown.Link.convert (Sources/MarkdownText/Inline/Markdown+InlineConvertible.swift, the container[.underlineStyle] = [] line) stores an empty Swift array as the .underlineStyle attribute value — in a [NSAttributedString.Key: Any] context the [] literal infers as an empty array, not as NSUnderlineStyle. TextKit expects an NSNumber there and AppKit calls -integerValue on it during layout, crashing NSTextView. the UIKit path tolerates the bad value, which is why iOS never crashed.

Minimal markdown input

a [link](https://example.com) is enough

Platform

macOS (the AppKit paragraph rendering layer; iOS is unaffected)

Expected behavior

the link renders styled and not underlined, as on iOS.

Actual behavior

the sample app crashes as soon as a document containing a link is rendered, e.g. opening the Kitchen Sink demo:

Thread 1: EXC_BREAKPOINT
FAULT: NSInvalidArgumentException: -[Swift.__EmptyArrayStorage integerValue]: unrecognized selector sent to instance

Validation

  • found while testing on the macOS sample app: opening the Kitchen Sink demo (full of links) crashes immediately; demos without links render fine.
  • iOS simulator renders the same fixtures correctly.
  • CI stays green because no snapshot/unit test currently renders a plain link on macOS (citation tests replace links with attachments).
  • fix is a one-liner (NSUnderlineStyle([]).rawValue) — PR with a regression test incoming.

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