Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-14552] SwiftSyntax crashes when parsing a malformed function type #400

allevato opened this issue Apr 30, 2021 · 2 comments

[SR-14552] SwiftSyntax crashes when parsing a malformed function type #400

allevato opened this issue Apr 30, 2021 · 2 comments


Copy link

@allevato allevato commented Apr 30, 2021

Previous ID SR-14552
Radar rdar://problem/77391988
Original Reporter @allevato
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s SwiftSyntax
Labels Bug
Assignee @ahoppen
Priority Medium

md5: 103052cad603311e83a1a277c4a8f594

Issue Description:

This is a repro of a case that recently started failing in one of swift-format's tests against the main branch (I'm using the 2021-04-26 development snapshot as my current environment).

When parsing the following source code:

{{ let x: (A -> B)}}

(Note that "A" should have its own parentheses surrounding it for this to be valid.)

The parser crashes with the following message:

Assertion failed: (isValid() && "length does not make sense for an invalid range"), function getByteLength, file /Users/buildnode/jenkins/workspace/oss-swift-package-macos/swift/include/swift/Basic/SourceLoc.h, line 218.

I would expect this to fail in some other, non-crashing fashion, such as expressing the syntax using Unknown* nodes.

To reproduce:

  1. Download the attached project.

  2. Use a development toolchain that is syntax-compatible with swift-syntax's main branch (at the time I'm writing this, 2021-04-26 worked).

  3. Run swift run TriviaCrash.

Copy link

@ahoppen ahoppen commented Apr 30, 2021

@swift-ci create

Copy link

@ahoppen ahoppen commented May 4, 2021

Thanks for reporting this @allevato. I’ve put up a

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants