Skip to content

Semantic Tokens: Object keys in uppercase emitted as namespace #797

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

Closed
aspeddro opened this issue Aug 3, 2023 · 4 comments · Fixed by #798
Closed

Semantic Tokens: Object keys in uppercase emitted as namespace #797

aspeddro opened this issue Aug 3, 2023 · 4 comments · Fixed by #798

Comments

@aspeddro
Copy link
Contributor

aspeddro commented Aug 3, 2023

ReScript-VSCode latest-master

image

@mooreryan
Copy link

Here is another case where tokens are getting called namespace rather than what it should be (in this case variable). (v1.18.0)

Color is weird:
a

Token output:

b
dr
c

@aspeddro
Copy link
Contributor Author

aspeddro commented Aug 8, 2023

let a = []
let abcdefghijklmn = 0
a[abcdefghijklmn] = 1

AST output:

[
  structure_item (/home/pedro/Desktop/learning-rescript/src/Object.res[1,0+0]..[1,0+10])
    Pstr_value Nonrec
    [
      <def>
        pattern (/home/pedro/Desktop/learning-rescript/src/Object.res[1,0+4]..[1,0+5])
          Ppat_var "a" (/home/pedro/Desktop/learning-rescript/src/Object.res[1,0+4]..[1,0+5])
        expression (/home/pedro/Desktop/learning-rescript/src/Object.res[1,0+8]..[1,0+10])
          Pexp_array
          []
    ]
  structure_item (/home/pedro/Desktop/learning-rescript/src/Object.res[2,11+0]..[2,11+22])
    Pstr_value Nonrec
    [
      <def>
        pattern (/home/pedro/Desktop/learning-rescript/src/Object.res[2,11+4]..[2,11+18])
          Ppat_var "abcdefghijklmn" (/home/pedro/Desktop/learning-rescript/src/Object.res[2,11+4]..[2,11+18])
        expression (/home/pedro/Desktop/learning-rescript/src/Object.res[2,11+21]..[2,11+22])
          Pexp_constant PConst_int (0,None)
    ]
  structure_item (/home/pedro/Desktop/learning-rescript/src/Object.res[3,34+0]..[3,34+21])
    Pstr_eval
    expression (/home/pedro/Desktop/learning-rescript/src/Object.res[3,34+0]..[3,34+21])
      Pexp_apply
      expression (/home/pedro/Desktop/learning-rescript/src/Object.res[3,34+1]..[3,34+17])
        Pexp_ident "Array.set" (/home/pedro/Desktop/learning-rescript/src/Object.res[3,34+1]..[3,34+17])
      [
        <arg>
        Nolabel
          expression (/home/pedro/Desktop/learning-rescript/src/Object.res[3,34+0]..[3,34+1])
            Pexp_ident "a" (/home/pedro/Desktop/learning-rescript/src/Object.res[3,34+0]..[3,34+1])
        <arg>
        Nolabel
          expression (/home/pedro/Desktop/learning-rescript/src/Object.res[3,34+2]..[3,34+16])
            Pexp_ident "abcdefghijklmn" (/home/pedro/Desktop/learning-rescript/src/Object.res[3,34+2]..[3,34+16])
        <arg>
        Nolabel
          expression (/home/pedro/Desktop/learning-rescript/src/Object.res[3,34+20]..[3,34+21])
            Pexp_constant PConst_int (1,None)
      ]
]

@aspeddro
Copy link
Contributor Author

aspeddro commented Aug 9, 2023

Is there any way to fix this without adding an attribute to this syntax sugar?

@cristianoc
Copy link
Collaborator

cristianoc commented Aug 9, 2023

It's probably the location of array set.
Which could maybe be made to match "=" at parser time instead of the entire lhs.
Or, the whole array set case special cased in the extension.

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.

3 participants