nishtahir / language-kotlin

Textmate language grammar for the Kotlin programming language
Apache License 2.0
12 stars 6 forks source link

"/*" interpreted as comment start even within a string. #68

Open pranjalvachaspati-toast opened 1 year ago

pranjalvachaspati-toast commented 1 year ago

For example, in


  public fun foo(
    argument1: String = "*/*",
    argument2: Map<String, String> = emptyMap(),
) {}

the "/*" in the argument1 default is treated as the beginning of a comment, and the rest of the code block is treated as a comment.

The Kotlin compiler does not treat it as a comment start, though (see https://pl.kotl.in/d9VnkkShu).

steliosfran commented 11 months ago

@nishtahir I was investigating the same issue today but didn't manage to fix it.

For some reason it only happens if this is within a function:

fun foo(argument: String = "image/*") {}

but not a val:

val foo = "image/*"

My initial assumption was that the issue is here:

patterns:
            -
                include: '#inline'
            -
                begin: '/\*'

because the begin clock does not check for double quotes, so I changed it to this begin: '(?<!")/\*' but the issue persists.