jonnyboyC / kos-language-server

A language server for the Kerboscript (kOS) a language for Kerbal Space Program
MIT License
25 stars 6 forks source link

[BUG] Language server wrongly(?) balks at integer lexicon keys #81

Closed jefferyharrell closed 5 years ago

jefferyharrell commented 5 years ago

The following code snippet...

@LAZYGLOBAL OFF.

DECLARE LOCAL foo IS LEXICON().

SET foo[1] TO "hello".

PRINT(foo[1]).

Results in a warning from the language server:

Can only use a string as a lexicon index.This may not able to be coerced into string type

Unless this is an upcoming change in kOS or something, this is not correct. For one thing, the program runs as expected. For another, the kOS docs say:

This is the most common use of a lexicon, to use strings as the key index values (and in fact why it’s called “lexicon”). However you can really use any value you feel like for the keys - strings, RGB colors, numbers, etc.

(https://ksp-kos.github.io/KOS/structures/collections/lexicon.html)

jonnyboyC commented 5 years ago

Thanks for the bug report. This has in a sense been fixed. I accidentally released a new version of the language server that displayed the type diagnostics. Currently the type system is still mostly a prototype that I'm incrementally improving.

Under the hood I believe kOS calls toString on each key. Every structure has the to string method, but since a number isn't a subclass of string, my current type checking cannot determine that it will be properly coerced into a string. I just released v0.8.1 which disables the type checking diagnostics until it's more consistently correct.

jonnyboyC commented 5 years ago

I believe this is also the case for #82

jefferyharrell commented 5 years ago

Very good, sir. Thank you for all your efforts.

jonnyboyC commented 5 years ago

Fixed with version 0.10.0