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

Kotlin destructuring declarations highlighted as syntax error #884

Open
1 task done
SebastianAigner opened this issue Nov 15, 2023 · 2 comments
Open
1 task done
Labels
help wanted lexer bug Highlighting error in a lexer

Comments

@SebastianAigner
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The following valid Kotlin code:

fun fromString(s: String): Passport {
    val fieldsAndValues = s.split(" ", "\n", "\r\n")
    val map = fieldsAndValues.associate {
        val (key, value) = it.split(":")
        key to value
    }
    return Passport(map)
}

is rendered as such:

Screenshot 2023-11-15 at 02 12 15

It seems that Chroma currently doesn't understand Kotlin destructuring declarations.

To Reproduce

See the playground.

@alecthomas alecthomas added help wanted lexer bug Highlighting error in a lexer and removed bug labels Nov 15, 2023
@alecthomas
Copy link
Owner

FYI: Chroma lexers are maintained by the community.

@jaller94
Copy link

Ideas:

  • Either change this rule to push a state of a new type property-or-property-group
  • Or allow property to be a group.
    • <state name="property">
      <rule pattern="\x60[^\x60]+?\x60">
      <token type="NameProperty"/>
      <pop depth="1"/>
      </rule>
      <rule pattern="(?:[_\p{L}][\p{L}\p{N}]*|`@?[_\p{L}][\p{L}\p{N}]+`)">
      <token type="NameProperty"/>
      <pop depth="1"/>
      </rule>
      </state>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted lexer bug Highlighting error in a lexer
Projects
None yet
Development

No branches or pull requests

3 participants