rhaiscript / lsp

Language server for Rhai.
Apache License 2.0
43 stars 4 forks source link

Scope variables and custom operators not recognized. #68

Closed schungx closed 2 years ago

schungx commented 2 years ago

In the definitions example, when I click open script.rhai:

image

However, hello_there is already defined in __scope__.d.rhai:

module static;

let hello_there;
schungx commented 2 years ago

Also, if I change the script to:

image

Although minus is defined in __static__.d.rhai:

module static;

op minus(int, int) -> int;

Nevertheless, custom operators may do weird things to the grammar though, so you can decide whether it is prudent to support it out-of-the-box.

tamasfe commented 2 years ago

Operators are ignored in the HIR right now (#66), the parser needs to know the allowed operator keywords so we need to process the definition files, and reparse the rest if the set of known custom keywords change.

The other issue is a bug, let definitions are ignored in definitions right now, if you change it to const, it will be recognized.

tamasfe commented 2 years ago

Huh, apparently lets were parsed but were missing from the AST definition.

schungx commented 2 years ago

The other issue is a bug, let definitions are ignored in definitions right now, if you change it to const, it will be recognized.

Got it. But if it is const, won't it be an error to assign to it?

tamasfe commented 2 years ago

Got it. But if it is const, won't it be an error to assign to it?

Yes, renaming it to const is just a temporary fix, I'm working on the lsp to accept and not to ignore let-s in definitions.

tamasfe commented 2 years ago

The let issue has been fixed, and custom operators are tracked in the other issue.