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

Chinese comments are not supported? #1138

Closed
cinema8150 opened this issue Feb 3, 2023 · 2 comments · Fixed by #1171
Closed

Chinese comments are not supported? #1138

cinema8150 opened this issue Feb 3, 2023 · 2 comments · Fixed by #1171
Assignees

Comments

@cinema8150
Copy link

cinema8150 commented Feb 3, 2023

Scan error when variable has Chinese comment like this:

import Foundation
struct AgeModel {
    var ageDesc: String // 年龄的描述
}

Error is:

➜  debug sourcery -v
Using configuration file at '.sourcery.yml'
Resolving configurations took 0.0025709867477416992
Scanning sources...
Swift/StringCharacterView.swift:158: Fatal error: String index is out of bounds
[1]    94313 illegal hardware instruction  sourcery -v

sourcery config is:

sources:
  - xxx/AgeModel.swift
templates:
  - xxx/temp
output:
  xxx/out

my templates is:

------------start------------

------------end------------

sourcery version is: 2.0.0, installed by brew

Success after remove Chinese comments or change to English, but there are too many Chinese comments .

@art-divin
Copy link
Collaborator

Hello @cinema8150 ,

thank you very much for reporting the issue 👍

I am analyzing this issue, and it seems like it has nothing to do with the comment, instead, AnnotationParser crashes on this line: .substring(to: max(0, lineInfo.character - 1)) while trying to evaluate spaces in front of var ageDesc: String statement. Seems like lines are miscalculated, and an empty line is passed to AnnotationParser's inlineFrom.

I'll keep you posted, I plan to resolve this today.

@art-divin
Copy link
Collaborator

Finished investigation: this is actually fixed in #1171 which seemed to be unrelated, but it is about how lines are parsed. Before they were against Swift grammar, and now they are parsed line SwiftSyntax would parse them.

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 a pull request may close this issue.

2 participants