ionide / ionide-fsgrammar

Shared Textmate Regex Style F# Language Grammar
MIT License
34 stars 36 forks source link

Unexpected grammar tokenization #174

Closed alexr00 closed 2 years ago

alexr00 commented 2 years ago

Hello, I'm a developer on VS Code and I noticed a possible bug when updating VS Code to use the latest ionide/ionide-fsgrammar. In the below example set was previously tokenized as source.fsharp binding.fsharp. After updating to commit 33c42ce4b0960c86837a978fa06c45bc3dec0521, set is tokenized as source.fsharp binding.fsharp variable.fsharp. This doesn't seem intentional as get is unchanged.

I haven't merged the update into VS Code yet as I wanted to confirm whether this is intentional, so you won't be able to reproduce this issue with VS Code's built in version of the fs grammar.

Syntax Colorization Failure

// from https://msdn.microsoft.com/en-us/library/dd233160.aspx

// The declaration creates a constructor that takes two values, name and age.
type Person(name:string, age:int) =
    let mutable internalAge = age

    new(name:string) = Person(name, 0)

    member this.Name = name
    // A read/write property.
    member this.Age
        with get() = internalAge
        and set(value) = internalAge <- value

    member this.HasABirthday () = internalAge <- internalAge + 1
    member this.IsOfAge targetAge = internalAge >= targetAge
    override this.ToString () =
        "Name:  " + name + "\n" + "Age:   " + (string)internalAge

System Details

baronfel commented 2 years ago

Thanks for reaching out! @MangelMaxime could https://github.com/ionide/ionide-fsgrammar/pull/173/files have introduced this? The grammar isn't my strongest area :)

MangelMaxime commented 2 years ago

@baronfel I think you are right and that this PR is probably the culpit.

I admit that when working on the grammars I mostly look at the color feedback and not the name of the scopes 😅.

I will have a look at it.

alexr00 commented 2 years ago

Thanks for the quick fix!